AuthProviderPluginClass Class
Contains methods to create a custom OAuth-based authentication provider plug-in for single sign-on in to Salesforce. Use this class to create a custom authentication provider plug-in if you can’t use one of the authentication providers that Salesforce provides.
To create a custom authentication provider for single sign-on, create a class that extends Auth.AuthProviderPluginClass. This class allows you to store the custom configuration for your authentication provider and handle authentication protocols when users log in to Salesforce with their login credentials for an external service provider. In Salesforce, the class that implements this interface appears in the Provider Type drop-down list in Auth. Providers in Setup. Make sure that the user you specify to run the class has “Customize Application” and “Manage Auth. Providers” permissions.
As of API version 39.0, use the abstract class AuthProviderPluginClass to create a custom external authentication provider. This class replaces the AuthProviderPlugin interface. If you’ve already implemented a custom authentication provider plug-in using the interface, it still works. However, use AuthProviderPluginClass to extend your plug-in. If you haven’t created an interface, create a custom authentication provider plug-in by extending this abstract class. For more information, see Create a Custom Authentication Provider Plug-in.
The AuthProviderPluginClass methods don’t support DML options.
This class doesn’t include a method for single logout. You can easily configure single logout in Setup. For steps, see Configure OpenID Connect Single Logout with Salesforce as the Relying Party in Salesforce Help. Alternatively, create custom methods for single logout.
-
Returns the custom metadata type API name for a custom OAuth-based authentication provider for single sign-on to Salesforce.
-
getUserInfo(authProviderConfiguration, response)
Returns information from the custom authentication provider about the current user. This information is used by the registration handler and in other authentication provider flows.
-
handleCallback(authProviderConfiguration, callbackState)
Uses the authentication provider’s supported authentication protocol to return an OAuth access token, OAuth secret or refresh token, and the state passed in when the request for the current user was initiated.
-
initiate(authProviderConfiguration, stateToPropagate)
Returns the URL where the user is redirected for authentication.
-
refresh(authProviderConfiguration, refreshToken)
Returns a new access token, which is used to update an expired access token.
Returns the custom metadata type API name for a custom OAuth-based authentication provider for single sign-on to Salesforce.
public String getCustomMetadataType()
Type: String
The custom metadata type API name for the authentication provider.
The getCustomMetatadaType() method returns only custom metadata type names. It does not return custom metadata record names. As of API version 39.0, use this method when extending Auth.AuthProviderPluginClass to create a custom external authentication provider.
Returns information from the custom authentication provider about the current user. This information is used by the registration handler and in other authentication provider flows.
public Auth.UserData getUserInfo(Map<String,String> authProviderConfiguration, Auth.AuthProviderTokenResponse response)
-
authProviderConfiguration:
The configuration for the custom authentication provider. When you create a custom metadata type in Salesforce, the configuration populates it with the custom metadata type default values. Or you can set the configuration with values that you enter when you create the custom provider in Auth. Providers in Setup.
-
response:
Type: Auth.AuthProviderTokenResponse
The OAuth access token, OAuth secret or refresh token, and state provided by the authentication provider to authenticate the current user.
Type: Auth.UserData
Creates a new instance of the Auth.UserData class.
As of API version 39.0, use this method when extending Auth.AuthProviderPluginClass to create a custom authentication provider.
Uses the authentication provider’s supported authentication protocol to return an OAuth access token, OAuth secret or refresh token, and the state passed in when the request for the current user was initiated.
public Auth.AuthProviderTokenResponse handleCallback(Map<String,String> authProviderConfiguration, Auth.AuthProviderCallbackState callbackState)
-
authProviderConfiguration:
The configuration for the custom authentication provider. When you create a custom metadata type in Salesforce, the configuration populates with the custom metadata type default values. Or you can set the configuration with values you enter when you create the custom provider in Auth. Providers in Setup.
-
callbackState:
Type: Auth.AuthProviderCallbackState
The class that contains the HTTP headers, body, and queryParams of the authentication request.
Type: Auth.AuthProviderTokenResponse
Creates an instance of the AuthProviderTokenResponse class.
As of API version 39.0, use this method when extending Auth.AuthProviderPluginClass to create a custom authentication provider.
Returns the URL where the user is redirected for authentication.
public System.PageReference initiate(Map<String,String> authProviderConfiguration, String stateToPropagate)
-
authProviderConfiguration:
The configuration for the custom authentication provider. When you create a custom metadata type in Salesforce, the configuration populates with the custom metadata type default values. Or you can set the configuration with values you enter when you create the custom provider in Auth. Providers in Setup.
-
stateToPropagate:
Type: String
The state passed in to initiate the authentication request for the user.
Type: System.PageReference
The URL of the page where the user is redirected for authentication.
As of API version 39.0, use this method when extending Auth.AuthProviderPluginClass to create a custom authentication provider.
Returns a new access token, which is used to update an expired access token.
public Auth.OAuthRefreshResult refresh(Map<String,String> authProviderConfiguration, String refreshToken)
-
authProviderConfiguration:
The configuration for the custom authentication provider. When you create a custom metadata type in Salesforce, the configuration populates with the custom metadata type default values. Or you can set the configuration with values you enter when you create the custom provider in Auth. Providers in Setup.
-
refreshToken:
Type: String
The refresh token for the user who is logged in.
Type: Auth.OAuthRefreshResult
Returns the new access token, or an error message if an error occurs.
A successful request returns a Auth.OAuthRefreshResult with the access token and refresh token in the response. If you receive an error, make sure that you set the error string to the error message. A NULL error string indicates no error.
The refresh method works only with named credentials; it doesn’t respect the standard OAuth refresh flow. The refresh method with named credentials works only if the earlier request returns a 401.
The following example demonstrates how to implement a custom Auth. provider plug-in using the abstract class, Auth.AuthProviderPluginClass.
The following example contains test classes for the Concur class.