-
Notifications
You must be signed in to change notification settings - Fork 456
NamedCredentialRecipes
pozil edited this page May 14, 2024
·
2 revisions
Demonstrates how to manage named credentials from Apex
Group Integration Recipes
public static ConnectApi createNamedCredential(ConnectApiWrapper connectApiWrapper, String permissionSetName)
Demonstrates how create a named credential from Apex.
Param | Description |
---|---|
connectApiWrapper |
instance of ConnectApiWrapper, created to allow mocking |
permissionSetName |
name of the permission set that will have access to the external credential |
Type | Description |
---|---|
ConnectApi |
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());
private static ConnectApi createExternalCredential(ConnectApiWrapper connectApiWrapper, String permissionSetName)
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.
Param | Description |
---|---|
connectApiWrapper |
instance of ConnectApiWrapper, created to allow mocking |
permissionSetName |
name of the permission set that will have access to the external credential |
Type | Description |
---|---|
ConnectApi |
ConnectApi.ExternalCredential The created external credential |
System.debug(NamedCredentialRecipes.createExternalCredential(new ConnectApiWrapper(), 'Apex_Recipes'));