ExternalClientAppOauthHandler Class
Contains methods for extending the behavior of an external client app. For example, customize how an external client app is invoked depending on the protocol used. This class gives you more control over the interaction between Salesforce and your external client app.
When you create an external client app, you specify general information about the app and settings for OAuth. To customize how the app is invoked, create a external client app handler with the ExternalClientAppOauthHandler Apex class. For example, use this class to support new authentication protocols or respond to user attributes in a way that benefits the business process.
When you create an external client app handler, you also configure the ExternalClientAppOauthHandler class to run as an execution user. The execution user authorizes access for the external client app. For example, when you use the authorize method, the execution user authorizes the external client app to access data.
If you don’t specify an execution user, the plug-in runs as an Automated Process User, which is a system user that executes tasks behind the scenes. Most ExternalClientAppOauthHandler methods require that you specify an execution user, with the exception of the customAttributes method.
The following are methods for ExternalClientAppOauthHandler.
-
authorize(userId, ecAppId, isAdminApproved, context)
Authorizes the specified user to access the external client app. If the external client app is set for users to self-authorize, this method isn’t invoked.
-
customAttributes(userId, ecAppId, formulaDefinedAttributes, context)
Sets new attributes for the specified user. When the external client app gets the user’s attributes from the UserInfo endpoint, use this method to update the attribute values.
-
refresh(userId, ecAppId, context)
Salesforce calls this method during a refresh token exchange.
Authorizes the specified user to access the external client app. If the external client app is set for users to self-authorize, this method isn’t invoked.
public Boolean authorize(Id userId, Id ecAppId, Boolean isAdminApproved, Auth.InvocationContext context)
-
userId:
Type: Id
The 15-character ID of the user attempting to use the external client app.
-
ecAppId:
Type: Id
The 15-character ID of the external client app.
-
isAdminApproved:
Type: Boolean
The approval state of the specified user when the external client app requires approval.
-
context:
Type: Auth.InvocationContext
The context in which the external client app is invoked.
Type: Boolean
A returned value of true indicates that the user is approved.
Sets new attributes for the specified user. When the external client app gets the user’s attributes from the UserInfo endpoint, use this method to update the attribute values.
public Map<String,String> customAttributes(Id userId, Id ecAppId, Map<String,String> formulaDefinedAttributes, Auth.InvocationContext context)
-
userId:
Type: Id
The 15-character ID of the user attempting to use the external client app.
-
ecAppId:
Type: Id
The 15-character ID for the external client app.
-
formulaDefinedAttributes:
A map of the current set of attributes from the UserInfo endpoint (OAuth) or from a SAML assertion. For more information, see The UserInfo Endpoint in the online help.
-
context:
Type: Auth.InvocationContext
The context in which the external client app is invoked.
A map of the updated set of attributes.
Salesforce calls this method during a refresh token exchange.
public void refresh(Id userId, Id ecAppId, Auth.InvocationContext context)
-
userId:
Type: Id
The 15-character ID of the user requesting the refresh token.
-
ecAppId:
Type: Id
The 15-character ID of the external client app.
-
context:
Type: Auth.InvocationContext
The context in which the external client app is invoked.
Type: void