Outbound OAuth2 Policy

Important: This page describes Classic APIM. For APIM 3.0, refer to API Management 3.0.
Adds an OAuth2 access token to each request that the proxy sends to the upstream API. The token comes from the OAuth2 account that the policy references, and the policy sets where the request carries it: in a header, in the request body, or in a query string parameter.
Note:
  • The OAuth2 Outbound policy isn't available for APIs and API versions.
  • The accounts used in the policy automatically reflect the changes made in the OAuth2 account itself.
  • If you delete an account, the policy that references it becomes invalid and displays an error until you select another account.

Prerequisites

An OAuth2 account in the global shared project. For an account type that has an Authorize button, authorize the account before you use it. To create one, refer to Create accounts.

Supported Account Types

The policy accepts the following account types:

Rule Execution Order

The Outbound OAuth2 policy executes after all policies, when the proxy calls the upstream API.

Field/Field set Description
When this policy should be applied An expression that defines one or more conditions that must be true for the policy to execute.

Example: The expression request.method == "POST" causes the policy to execute only on POST requests.

Token Location Required. Select where the request carries the token: Header, Body, or Query.

Default value: Header

Authorization Scheme

Appears when Token Location is Header.

Select the scheme that precedes the token in the Authorization header:
  • Bearer: The header value is Bearer <access-token>.
  • Custom: The header value starts with the scheme that you enter in Custom Authorization Scheme.

Default value: Bearer

Custom Authorization Scheme

Appears when Authorization Scheme is Custom.

Enter the scheme to send before the token.
Request Body Key

Appears when Token Location is Body.

Enter the JSON key that holds the token in the request body.

Example: access_token

Query String Parameter Name

Appears when Token Location is Query.

Enter the name of the query string parameter that holds the token.

Example: access_token

Status Select to enable the policy.

Default status: Selected

Account Reference Select an OAuth2 account in the global shared project.

Default value: N/A

Example: ../../shared/OutboundPolicyRestOAuth2

Description

Required. A brief description of this policy.

Default value: Outbound requests are being authenticated using specified OAuth2 service

Example: Dev Env Outbound OAuth