The OAuth 2.0 Validate Access Token filter is used to validate a specified access token contained in persistent storage. OAuth access tokens are used to grant access to specific resources in an HTTP service for a specific period of time (for example, photos on a photo sharing website). This enables users to grant third-party applications access to their resources without sharing all of their data and access permissions.
For more details on supported OAuth flows, see API Gateway OAuth 2.0 authentication flows.
Configure the following fields:
Name:
Enter a suitable name for this filter.
Verify access token is in cache:
Click the browse button to select the cache in which to verify the access token (for example, in the default OAuth Access Token Store). To add an access token store, right-click Access Token Stores, and select Add Access Token Store. You can store tokens in a cache, in a relational database, or in an embedded Cassandra database. For more details, see Manage access tokens and authorization codes.
Location of access token:
Select one of the following:
Bearer
. This is the default option. Validate Scopes:
Select whether scopes match Any
or All
of the configured scopes in the table, and click Add
to add an OAuth scope. The default scopes are found in ${http.request.uri}.
For example, the default scopes used in the OAuth demos are resource.READ
and resource.WRITE.
The Validate Access Token filter performs a number of checks to determine if the token is valid. If any of the checks fail, the response can be examined to determine the reason for the failure.
The filter performs the following sequence of steps to determine if the token is valid:
HTTP/1.1 400 Bad Request WWW-Authenticate:Bearer realm="DefaultRealm", error="invalid_request", error_description="Unable to find token in the message." |
HTTP/1.1 401 Unauthorized WWW-Authenticate:Bearer realm="DefaultRealm" |
HTTP/1.1 401 Unauthorized WWW-Authenticate:Bearer realm="DefaultRealm", error="invalid_token", error_description="Unable to find the access token in persistent storage." |
HTTP/1.1 401 Unauthorized WWW-Authenticate:Bearer realm="DefaultRealm", error="invalid_token", error_description="The access token expired." |
HTTP/1.1 401 Unauthorized WWW-Authenticate:Bearer realm="DefaultRealm", error="invalid_token", error_description="The client app was not found or is disabled." |
HTTP/1.1 403 Forbidden WWW-Authenticate:Bearer realm="DefaultRealm", error="insufficient_scope", error_description="scope(s) associated with access token are not valid to access this resource.", scope="Scopes must match Any of these scopes:resource.WRITE" |