NamedCredentials Class
Namespace
NamedCredentials Methods
createCredential(requestBody)
API Version
56.0
Requires Chatter
No
Signature
public static ConnectApi.Credential createCredential(ConnectApi.CredentialInput requestBody)
Parameters
- requestBody
- Type: ConnectApi.CredentialInput
- A ConnectApi.CredentialInput class.
Return Value
Type: ConnectApi.Credential
createCredential(requestBody, action)
API Version
58.0
Requires Chatter
No
Signature
public static ConnectApi.Credential createCredential(ConnectApi.CredentialInput requestBody, ConnectApi.CreateCredentialAction action)
Parameters
- requestBody
- Type: ConnectApi.CredentialInput
- A ConnectApi.CredentialInput class.
- action
- Type: ConnectApi.CreateCredentialAction
- Action to take when creating the
credential.
Value is:
- Refresh
Return Value
Type: ConnectApi.Credential
createExternalAuthIdentityProvider(requestBody)
API Version
62.0
Requires Chatter
No
Signature
public static ConnectApi.ExternalAuthIdentityProvider createExternalAuthIdentityProvider(ConnectApi.ExternalAuthIdentityProviderInput requestBody)
Parameters
- requestBody
- Type: ConnectApi.ExternalAuthIdentityProviderInput
- A ConnectApi.ExternalAuthIdentityProviderInput input class.
Return Value
createExternalAuthIdentityProviderCredentials(fullName, requestBody)
API Version
62.0
Requires Chatter
No
Signature
public static ConnectApi.ExternalAuthIdentityProviderCredentials createExternalAuthIdentityProviderCredentials(String fullName, ConnectApi.ExternalAuthIdentityProviderCredentialsInput requestBody)
Parameters
- fullName
- Type: String
- Full name of the external auth identity provider to create credentials for.
- requestBody
- Type: ConnectApi.ExternalAuthIdentityProviderCredentialsInput
- A ConnectApi.ExternalAuthIdentityProviderCredentialsInput input class
Return Value
createExternalCredential(requestBody)
API Version
58.0
Requires Chatter
No
Signature
public static ConnectApi.ExternalCredential createExternalCredential(ConnectApi.ExternalCredentialInput requestBody)
Parameters
- requestBody
- Type: ConnectApi.ExternalCredentialInput
- Input used to create or update an external credential.
Return Value
createNamedCredential(requestBody)
API Version
58.0
Requires Chatter
No
Signature
public static ConnectApi.NamedCredential createNamedCredential(ConnectApi.NamedCredentialInput requestBody)
Parameters
- requestBody
- Type: ConnectApi.NamedCredentialInput
- Input used to create or update a named credential.
Return Value
deleteCredential(externalCredential, principalName, principalType)
This method deletes the user external credentials that store the encrypted access tokens used for named credential callouts, not the external credential itself. You can delete an external credential only in the UI or by using REST API.
API Version
56.0
Requires Chatter
No
Signature
public static Void deleteCredential(String externalCredential, String principalName, ConnectApi.CredentialPrincipalType principalType)
Parameters
- externalCredential
- Type: String
- Fully qualified developer name of the external credential.
- principalName
- Type: String
- Name of the external credential named principal.
- principalType
- Type: ConnectApi.CredentialPrincipalType
- Type of credential principal. Values are:
- AwsStsPrincipal
- NamedPrincipal
- PerUserPrincipal
Return Value
Type: Void
deleteCredential(externalCredential, principalName, principalType, authenticationParameters)
This method deletes the user external credentials that store the encrypted access tokens used for named credential callouts, not the external credential itself. You can delete an external credential only in the UI or by using REST API.
API Version
59.0
Requires Chatter
No
Signature
public static Void deleteCredential(String externalCredential, String principalName, ConnectApi.CredentialPrincipalType principalType, List<String> authenticationParameters)
Parameters
- externalCredential
- Type: String
- Fully qualified developer name of the external credential.
- principalName
- Type: String
- Name of the external credential named principal.
- principalType
- Type: ConnectApi.CredentialPrincipalType
- Type of credential principal. Values are:
- AwsStsPrincipal
- NamedPrincipal
- PerUserPrincipal
- authenticationParameters
- Type: List<String>
- List of authentication parameters only for custom protocols, for example myApiKey,myApiSecret. If unspecified, all credentials are deleted.
Return Value
Type: Void
deleteExternalAuthIdentityProvider(fullName)
API Version
62.0
Requires Chatter
No
Signature
public static Void deleteExternalAuthIdentityProvider(String fullName)
Parameters
- fullName
- Type: String
- Full name of the external auth identity provider to delete.
Return Value
Type: Void
getCredential(externalCredential, principalName, principalType)
API Version
56.0
Requires Chatter
No
Signature
public static ConnectApi.Credential getCredential(String externalCredential, String principalName, ConnectApi.CredentialPrincipalType principalType)
Parameters
- externalCredential
- Type: String
- Fully qualified developer name of the external credential.
- principalName
- Type: String
- Name of the external credential named principal.
- principalType
- Type: ConnectApi.CredentialPrincipalType
- Type of credential principal. Values are:
- AwsStsPrincipal
- NamedPrincipal
- PerUserPrincipal
Return Value
Type: ConnectApi.Credential
getExternalAuthIdentityProvider(fullName)
API Version
62.0
Requires Chatter
No
Signature
public static ConnectApi.ExternalAuthIdentityProvider getExternalAuthIdentityProvider(String fullName)
Parameters
- fullName
- Type: String
- Full name of the external auth identity provider.
Return Value
getExternalAuthIdentityProviderCredentials(fullName)
API Version
62.0
Requires Chatter
No
Signature
public static ConnectApi.ExternalAuthIdentityProviderCredentials getExternalAuthIdentityProviderCredentials(String fullName)
Parameters
- fullName
- Type: String
- Full name of the external auth identity provider.
Return Value
getExternalAuthIdentityProviders()
API Version
62.0
Requires Chatter
No
Signature
public static ConnectApi.ExternalAuthIdentityProviderList getExternalAuthIdentityProviders()
Return Value
getExternalCredential(developerName)
API Version
56.0
Requires Chatter
No
Signature
public static ConnectApi.ExternalCredential getExternalCredential(String developerName)
Parameters
- developerName
- Type: String
- Fully qualified developer name of the external credential.
Return Value
getExternalCredentials()
API Version
56.0
Requires Chatter
No
Signature
public static ConnectApi.ExternalCredentialList getExternalCredentials()
Return Value
getNamedCredential(developerName)
API Version
59.0
Requires Chatter
No
Signature
public static ConnectApi.NamedCredential getNamedCredential(String developerName)
Parameters
- developerName
- Type: String
- Fully qualified developer name of the named credential.
Return Value
getNamedCredentials()
API Version
59.0
Requires Chatter
No
Signature
public static ConnectApi.NamedCredentialList getNamedCredentials()
Return Value
getOAuthCredentialAuthUrl(requestBody)
API Version
56.0
Requires Chatter
No
Signature
public static ConnectApi.OAuthCredentialAuthUrl getOAuthCredentialAuthUrl(ConnectApi.OAuthCredentialAuthUrlInput requestBody)
Parameters
- requestBody
- Type: ConnectApi.OAuthCredentialAuthUrlInput
- A ConnectApi.OAuthCredentialAuthUrlInput class indicating the OAuth authentication flow.
Return Value
Usage
Accepts input parameters representing a specific external credential and, optionally, a named principal. Returns the URL a user must visit to begin the authentication flow, ultimately returning authentication tokens to Salesforce. Use this method as part of building a customized or branded user interface to help users initiate authentication.
Example
ConnectApi.OAuthCredentialAuthUrlInput input = new ConnectApi.OAuthCredentialAuthUrlInput();
input.externalCredential = 'MyExternalCredentialDeveloperName';
input.principalType = ConnectApi.CredentialPrincipalType.PerUserPrincipal;
input.principalName = 'MyPrincipal'; // Only required when principalType = NamedPrincipal
ConnectApi.OAuthCredentialAuthUrl output = ConnectApi.NamedCredentials.getOAuthCredentialAuthUrl(input);
String authenticationUrl = output.authenticationUrl; // Redirect users to this URL to authenticate in the browser
patchCredential(requestBody)
This method updates custom credentials. To replace a credential, use updateCredential(requestBody).
API Version
59.0
Requires Chatter
No
Signature
public static ConnectApi.Credential patchCredential(ConnectApi.CredentialInput requestBody)
Parameters
- requestBody
- Type: ConnectApi.CredentialInput
- A ConnectApi.CredentialInput class. Only the custom credentials in the input class are updated.
Return Value
Type: ConnectApi.Credential
updateCredential(requestBody)
This method uses the ConnectApi.CredentialInput and the ConnectApi.CredentialValueInput input classes to replace a credential’s values. In the UI, these values appear as the credential’s authentication parameters. To update a credential, use patchCredential(requestBody).
API Version
56.0
Requires Chatter
No
Signature
public static ConnectApi.Credential updateCredential(ConnectApi.CredentialInput requestBody)
Parameters
- requestBody
- Type: ConnectApi.CredentialInput
- A ConnectApi.CredentialInput class.
Return Value
Type: ConnectApi.Credential
updateExternalAuthIdentityProvider(fullName, requestBody)
API Version
62.0
Requires Chatter
No
Signature
public static ConnectApi.ExternalAuthIdentityProvider updateExternalAuthIdentityProvider(String fullName, ConnectApi.ExternalAuthIdentityProviderInput requestBody)
Parameters
- fullName
- Type: String
- Full name of the external auth identity provider to update.
- requestBody
- Type: ConnectApi.ExternalAuthIdentityProviderInput
- A ConnectApi.ExternalAuthIdentityProviderInput input class.
Return Value
updateExternalAuthIdentityProviderCredentials(fullName, requestBody)
API Version
62.0
Requires Chatter
No
Signature
public static ConnectApi.ExternalAuthIdentityProviderCredentials updateExternalAuthIdentityProviderCredentials(String fullName, ConnectApi.ExternalAuthIdentityProviderCredentialsInput requestBody)
Parameters
- fullName
- Type: String
- The external auth identity provider credentials to replace.
- requestBody
- Type: ConnectApi.ExternalAuthIdentityProviderCredentialsInput
- A ConnectApi.ExternalAuthIdentityProviderCredentialsInput input class.