Skip to Content

Azure AD 2-legged OAuth 2.0 API Security Profile

Introduction

Important

Azure Active Directory (Azure AD) is now known as Microsoft Entra ID.

Within a security profile, you can configure Microsoft Azure Active Directory (Azure AD) as an OAuth 2.0 identity provider to provide API consumers access to an API using Azure AD authentication.

This page shows how to configure and use Azure AD authentication with a Jitterbit Custom, OData, or Proxy API by following these steps:

  1. Configuring Azure AD as an Identity Provider
    Configure the Azure AD instance as an identity provider to use as input for configuring a security profile in API Manager.
  2. Granting API Permissions to Harmony
    Grant Harmony permissions to use the Azure AD APIs with the OAuth 2.0 application you created in the previous step.
  3. Configuring a Security Profile in API Manager
    Configure Azure AD as the identity provider in API Manager.
  4. Assigning a Security Profile in API Manager
    Assign the security profile to one or more Jitterbit Custom, OData, or Proxy APIs.
  5. Accessing an API with Azure AD Authentication
    API consumers are then able to use Azure AD authentication to consume Jitterbit Custom, OData, or Proxy APIs that the security profile is assigned to.

For additional information, see Microsoft's Configure an OpenID Connect OAuth application from Microsoft Entra app gallery documentation.

For Azure AD 3-legged OAuth security profile configuration, see Azure AD 3-legged OAuth 2.0 API Security Profile.

Prerequisites

Microsoft Azure AD Premium P1 edition is required to set up and use Azure AD as an identity provider.

1. Configuring Azure AD as an Identity Provider

Follow these steps to configure an OAuth 2.0 application in the Microsoft Azure portal and obtain the Client ID, Client Secret, and Directory ID needed for configuring Azure AD as an identity provider for a security profile:

  1. Log in to the Microsoft Azure portal.

  2. In the Microsoft Azure portal, go to App registrations and click New registration:

    msft new registration annotated

  3. On the Register an application screen, specify the initial details of the application:

    attachment

    • Enter a Name. For example, Jitterbit API Manager APIs.
    • Under Supported account types, select the appropriate option for your situation.
  4. After clicking Register, on the Overview screen for the new application, the Application (client) ID and Directory (tenant) ID are displayed. Retain these for later use, as they will be required when configuring the security profile in API Manager:

    attachment

  5. Under the Manage category on the left, select Certificates & secrets. Then, under Client secrets, click New client secret:

    attachment

  6. Provide a Description and set the secret to Never expire. Then click Add:

    attachment

  7. Use the Copy to clipboard icon to copy the new client secret. Retain this for later use, as it will be required when configuring the security profile in API Manager.

    attachment

2. Granting API Permissions to Harmony

Follow these steps to grant Harmony permissions to use the Azure AD APIs with the OAuth 2.0 application that you created in the section Configuring Azure AD as an Identity Provider. If continuing from the previous section, you can start at step 3 below.

  1. Log in to the Microsoft Azure portal.

  2. In the Microsoft Azure portal, go to App registrations and select the OAuth 2.0 application that you created in the section Configuring Azure AD as an Identity Provider (in the example, called Jitterbit API Manager APIs).

  3. Under the Manage category on the left, select API permissions. Then, under Configured permissions, click Add a permission:

    attachment

  4. On the Request API permissions screen, under the Microsoft APIs tab, select the Microsoft Graph API:

    attachment

  5. On the Request API permissions screen, select Delegated permissions:

    attachment

  6. The section Select permissions is now displayed. Within it, select these permissions:

    • Under OpenId permissions, select offline_access, openid, and profile:

      attachment

    • Under User, select User.Read:

      attachment

  7. Once these permissions have been selected, at the bottom of the Request API permissions screen, click Add permissions.

  8. You are returned to the API permissions screen for the application. Under Configured permissions, click Grant admin consent for \<Directory>:

    attachment

  9. Acknowledge the dialog to grant consent for the directory:

    attachment

  10. Under Configured permissions, the Status column should now show that consent has been granted for each added permission:

    attachment

  11. Follow these additional steps to create a custom scope:

    1. Navigate to Expose an API and click Add a scope.
    2. In the Add a scope dialog, enter a Scope name, Admin consent display name, Admin consent description, and complete the optional fields as desired. Click Add scope:

      attachment

  12. Under the Manage category on the left, select Manifest. Ensure that accessTokenAcceptedVersion is set to 2 and click Save:

    attachment

    Caution

    Your authentication token will not validate if accessTokenAcceptedVersion is not set to 2.

3. Configuring a Security Profile in API Manager

Follow the instructions for Configuring a Security Profile in Security Profile Configuration.

Caution

The Profile Name must not contain any spaces. If the Profile Name contains spaces, you will receive an error when attempting to access an API using that security profile. Azure AD returns an error similar to this:

The reply URL specified in the request does not match the reply URLs configured for the application.

During configuration, select OAuth 2.0 as the authentication Type and Azure AD as the OAuth Provider:

attachment

Enter the scope in the OAuth Scope field. The scope name is <client_id>/.default. The client ID was obtained above in step 1.

attachment

The Authorized Domains field must be empty:

attachment

Optionally, enter the OAuth Client ID and OAuth Client Secret (for testing purposes) obtained above in step 1:

attachment

Enter the audience, which is your app's Application ID (client ID), assigned to your app in the Azure portal as described above in step 1.

attachment

Edit the OpenID Discovery URL, the OAuth Authorization URL, the OAuth Token URL, and the User Info URL to replace the placeholder directory ID (yourDirectoryID) with the Directory ID obtained above in step 1.

attachment

attachment

Once the above fields have been populated, click Test to validate the authentication token.

4. Assigning a Security Profile in API Manager

To use the security profile with an API, follow the instructions for configuring a Custom API, OData Service, or Proxy API and select the security profile configured with Azure AD OAuth 2.0 authentication.

5. Accessing an API with Azure AD Authentication

Once you have saved and published a Custom API, OData Service, or Proxy API, its API is accessible by URL in the application calling the API using the configured authentication method.

Using 2-legged OAuth 2.0 is a two-step process:

  1. Generate an OAuth token either by passing the Azure client ID and client secret obtained above in step 1 in an RFC6749 Client Credentials Access Token Request to the new 2-legged OAuth Token URL link displayed on the Security Profiles page or by obtaining the OAuth token directly from Azure AD.
  2. Send the OAuth token in the API header using the "bearer" token type defined in RFC6750.

To consume the API, use the link to Copy URL and use it within the calling application:

attachment

If the API supports GET, you can also paste the URL into a web browser to consume the API manually.

When 2-legged OAuth Flow is being used, the API Gateway fetches the access token and authentication takes place automatically.

If the authentication is successful, the expected payload is displayed in the web browser.