Newer Version Available
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
deleteCredential(externalCredential, principalName, principalType)
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
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
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
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
1ConnectApi.OAuthCredentialAuthUrlInput input = new ConnectApi.OAuthCredentialAuthUrlInput();
2
3input.externalCredential = 'MyExternalCredentialDeveloperName';
4input.principalType = ConnectApi.CredentialPrincipalType.PerUserPrincipal;
5input.principalName = 'MyPrincipal'; // Only required when principalType = NamedPrincipal
6
7ConnectApi.OAuthCredentialAuthUrl output = ConnectApi.NamedCredentials.getOAuthCredentialAuthUrl(input);
8
9String authenticationUrl = output.authenticationUrl; // Redirect users to this URL to authenticate in the browserupdateCredential(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