extraMetadata
field in the API definition. The response from the auth server will be parsed for any fields defined in extraMetadata
; any matches will be saved to the request context where they can be accessed from other middleware (for our example, the URL rewrite middleware could be used to modify the upstream target URL).
x-tyk-api-gateway
) within the Tyk OAS API definition by adding the authentication
section within the upstream
section.
Set upstream.authentication.enabled
to true
to enable upstream authentication.
For OAuth 2.0 Client Credentials, you will need to add the oauth
section within upstream.authentication
.
This has the following parameters:
enabled
set this to true
to enable upstream OAuth authenticationallowedAuthorizeTypes
should include the value clientCredentials
clientCredentials
should be configured with:
tokenUrl
is the URL of the /token
endpoint on the auth serverclientId
is the client ID to be provided to the auth serverclientSecret
is the client secret to be provided to the auth serverscopes
is an optional array of authorization scopes to be requestedextraMetadata
is an optional array of additional fields to be extracted from the auth server responseheader.enabled
must be set to true
if your upstream expects the credentials to be in a custom header, otherwise it can be omitted to use Authorization
headerheader.name
is the custom header to be used if header.enabled
is set to true
header
parameter - even if you are using the default Authorization
value.
For example:
http://<my-auth-server>
providing client credentials and the scope scope1
.
Tyk will parse the response from the authorization server for the key instance_url
, storing any value found in the request context were it can be accessed by other middleware as $tyk_context.instance_url
(note the rules on accessing request context variables from middleware).
On receipt of an access token from the authorization server, Tyk will proxy the original request to the upstream server (https://httpbin.org/
) passing the access token in the Authorization
header.
If you replace the upstream.url
and authorization server details with valid details, then the configuration above is a complete and valid Tyk OAS API Definition that you can import into Tyk to try out the Upstream OAuth 2.0 Client Credentials feature.
x-tyk-api-gateway
) within the Tyk OAS API definition by adding the authentication
section within the upstream
section.
Set upstream.authentication.enabled
to true
to enable upstream authentication.
For OAuth 2.0 Resource Owner Password Credentials (Password Grant), you will need to add the oauth
section within upstream.authentication
.
This has the following parameters:
enabled
set this to true
to enable upstream OAuth authenticationallowedAuthorizeTypes
should include the value password
password
should be configured with:
tokenUrl
is the URL of the /token
endpoint on the auth serverclientId
is the client ID to be provided to the auth serverclientSecret
is the client secret to be provided to the auth serverusername
is the Resource Owner username to be provided to the auth serverpassword
is the Resource Owner password to be provided to the auth serverscopes
is an optional array of authorization scopes to be requestedextraMetadata
is an optional array of additional fields to be extracted from the auth server responseheader.enabled
must be set to true
if your upstream expects the credentials to be in a custom header, otherwise it can be omitted to use Authorization
headerheader.name
is the custom header to be used if header.enabled
is set to true
header
parameter - even if you are using the default Authorization
value.
For example:
http://<my-auth-server>
providing client credentials, resource owner credentials and the scope scope1
.
Tyk will parse the response from the authorization server for the key instance_url
, storing any value found in the request context were it can be accessed by other middleware as $tyk_context.instance_url
(note the rules on accessing request context variables from middleware).
On receipt of an access token from the authorization server, Tyk will proxy the original request to the upstream server (https://httpbin.org/
) passing the access token in the Authorization
header.
If you replace the upstream.url
and authorization server details with valid details, then the configuration above is a complete and valid Tyk OAS API Definition that you can import into Tyk to try out the Upstream OAuth 2.0 Password Grant feature.