-
Notifications
You must be signed in to change notification settings - Fork 458
NamedCredentialRecipes
pozil edited this page Nov 14, 2024
·
5 revisions
Demonstrates how to manage named credentials from Apex
Group Integration Recipes
public static final NAMED_CREDENTIAL_MASTER_LABEL
String
public static final NAMED_CREDENTIAL_DEVELOPER_NAME
String
public static final NAMED_CREDENTIAL_TYPE
ConnectApi.NamedCredentialType
public static final NAMED_CREDENTIAL_CALLOUT_URL
String
public static final NAMED_CREDENTIAL_ALLOW_MERGE_FIELDS_IN_BODY
Boolean
public static final NAMED_CREDENTIAL_ALLOW_MERGE_FIELDS_IN_HEADER
Boolean
public static final NAMED_CREDENTIAL_GENERATE_AUTH_HEADER
Boolean
public static final EXTERNAL_CREDENTIAL_MASTER_LABEL
String
public static final EXTERNAL_CREDENTIAL_DEVELOPER_NAME
String
public static final EXTERNAL_CREDENTIAL_AUTHENTICATION_PROTOCOL
ConnectApi.CredentialAuthenticationProtocol
public static final PRINCIPAL_NAME
String
public static final PRINCIPAL_TYPE
ConnectApi.CredentialPrincipalType
public static final PRINCIPAL_SEQUENCE_NUMBER
Integer
Demonstrates how create a named credential from Apex.
public static ConnectApi.NamedCredential createNamedCredential(ConnectApiWrapper connectApiWrapper, String permissionSetName)
Name | Type | Description |
---|---|---|
connectApiWrapper | ConnectApiWrapper | instance of ConnectApiWrapper, created to allow mocking |
permissionSetName | String | name of the permission set that will have access to the external credential |
ConnectApi.NamedCredential
The created named credential
System.debug(NamedCredentialRecipes.createNamedCredential(new ConnectApiWrapper(), 'Apex_Recipes'));
HttpResponse response = RestClient.makeApiCall(
NAMED_CREDENTIAL_DEVELOPER_NAME,
RestClient.HttpVerb.GET,
'/volumes?q=salesforce'
);
System.debug(response.getBody());
This example shows how to create an external credential in Apex. An external credential contains the authentication and authorization information for the callout, and needs to be linked to a named credential in order to be used.
private static ConnectApi.ExternalCredential createExternalCredential(ConnectApiWrapper connectApiWrapper, String permissionSetName)
Name | Type | Description |
---|---|---|
connectApiWrapper | ConnectApiWrapper | instance of ConnectApiWrapper, created to allow mocking |
permissionSetName | String | name of the permission set that will have access to the external credential |
ConnectApi.ExternalCredential
The created external credential
System.debug(NamedCredentialRecipes.createExternalCredential(new ConnectApiWrapper(), 'Apex_Recipes'));