Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Get an Authentication URL
Call a method to get an authentication URL.
Call getOAuthCredentialAuthUrl(requestBody) to retrieve the URL that a user
must visit to begin an authentication flow, ultimately returning authentication tokens to
Salesforce. Accepts input parameters representing a specific external credential and,
optionally, a named principal. Use this method as part of building a customized or branded
user interface to help users initiate authentication.
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 browser