TokenValidationResult Class
Contains methods that describe the result of the token validation performed by a token exchange handler using the validateIncomingToken method in the Auth.Oauth2TokenExchangeHandler class during the OAuth 2.0 token exchange flow.
For a full example implementation that shows how to get information from the TokenValidationResult class, see OAuth 2.0 Token Exchange Handler Examples.
Here’s is an example of the Auth.TokenValidationResult class.
The following are constructors for TokenValidationResult.
-
TokenValidationResult(isValid, data, userData, token, tokenType, customErrorMsg)
Creates an instance of the
Auth.TokenValidationResultclass to describe the result of token validation performed during the OAuth 2.0 token exchange flow. -
Creates an instance of the
Auth.TokenValidationResultclass to describe a valid token validation result during the OAuth 2.0 token exchange flow.
Creates an instance of the Auth.TokenValidationResult class to describe the result of token validation performed during the OAuth 2.0 token exchange flow.
public TokenValidationResult(Boolean isValid, Object data, Auth.UserData userData, String token, Auth.OAuth2TokenExchangeType tokenType, String customErrorMsg)
-
isValid:
Type: Boolean
If
true, the token is valid. -
data:
Type:
Object Stores
custom data that isn’t stored in
userData. -
userData:
Type: Auth.UserData
Stores information about
a Salesforce user.
-
token:
Type: String
The token from the external identity provider.
-
tokenType:
Type: Auth.OAuth2TokenExchangeType
The type of token from the external identity provider.
-
customErrorMsg:
Type: String
A custom error message that’s returned if the token validation fails.
Creates an instance of the Auth.TokenValidationResult class to describe a valid token validation result during the OAuth 2.0 token exchange flow.
public TokenValidationResult(Boolean valid)
-
valid:
Type: Boolean
Indicates a valid token validation result.
The following are properties for TokenValidationResult.
-
A custom error message that’s returned if token validation fails.
-
Contains information about the user that isn’t stored in the
Auth.UserDataclass, such as information obtained via callouts to the external identity provider. -
Indicates whether the token is valid or not, based on the custom validation logic in your token exchange handler.
-
The token from the external identity provider.
-
The type of token from the external identity provider. It can be an access token, refresh token, ID token, SAML 2.0 assertion, or a JSON Web Token (JWT).
-
Information about the user that’s obtained from the identity provider’s token.
A custom error message that’s returned if token validation fails.
public String customErrorMsg {get; set;}
Type: String
Contains information about the user that isn’t stored in the Auth.UserData class, such as information obtained via callouts to the external identity provider.
public Object data {get; set;}
Type: Object
Indicates whether the token is valid or not, based on the custom validation logic in your token exchange handler.
public Boolean isValid {get; set;}
Type: Boolean
The token from the external identity provider.
public String token {get; set;}
Type: String
The type of token from the external identity provider. It can be an access token, refresh token, ID token, SAML 2.0 assertion, or a JSON Web Token (JWT).
public Auth.OAuth2TokenExchangeType tokenType {get; set;}
Type: Auth.OAuth2TokenExchangeType
Information about the user that’s obtained from the identity provider’s token.
public Auth.UserData userData {get; set;}
Type: Auth.UserData
The following are methods for TokenValidationResult.
-
Retrieves the
CustomErrorMsgthat’s returned when token validation fails. -
Retrieves data from the identity provider token. This data can include custom data that isn’t stored in the
userDataproperty. -
Retrieves the token that was passed from the external identity provider.
-
Retrieves the type of token that was passed from the external identity provider.
-
Retrieves information about the user. The user information can be obtained from the identity provider’s token or from callouts to the identity provider, if applicable.
-
Indicates whether the token is valid or not, based on the custom validation logic in your token exchange handler.
Retrieves the CustomErrorMsg that’s returned when token validation fails.
public String getCustomErrorMessage()
Type: String
Retrieves data from the identity provider token. This data can include custom data that isn’t stored in the userData property.
public Object getData()
Type: Object
Retrieves the token that was passed from the external identity provider.
public String getToken()
Type: String
Retrieves the type of token that was passed from the external identity provider.
public Auth.OAuth2TokenExchangeType getTokenType()
Type: Auth.OAuth2TokenExchangeType
Retrieves information about the user. The user information can be obtained from the identity provider’s token or from callouts to the identity provider, if applicable.
public Auth.UserData getUserData()
Type: Auth.UserData
Indicates whether the token is valid or not, based on the custom validation logic in your token exchange handler.
public Boolean isValid {get; set;}
Type: Boolean