Enabling OAuth 2.0 Authentication with Azure Active Directory (2024)

When you use OAuth 2.0 authentication, you get access to a web service from a client application. The way you do this depends on the grant you use. In this tutorial, we will show how to configure the client credentials grant type for applications in Azure Active Directory. In the Client Credentials Grant type, the client application gets access to the web service by using its own credentials.

1. Register applications in Azure Active Directory

To be able to perform OAuth 2.0 authentication by using the client credentials grant type, you need to register both the web service and the client applications in Azure Active Directory. To learn how to do this, see the Microsoft documentation.

2. Configure a client application

A client application is an application that requests a protected resource. After you register it in Azure Active Directory, you need to perform the following steps to apply the client credentials grant type:

  1. Open the Azure Active Directory service. In App registrations, open the registration of your client application.

  2. Copy the Application (client) ID to some place. You will need it to link the client to the web service and to configure the request authentication:

    Enabling OAuth 2.0 Authentication with Azure Active Directory (1)

    Click the image to enlarge it.

  3. In the Client Credentials Grant type, you will need a client secret. To get it, open the Certificates & secrets page and click New client secret:

    Add a short description and click Add.

  4. Copy the generated value to some place:

    Enabling OAuth 2.0 Authentication with Azure Active Directory (3)

    Click the image to enlarge it.

    Enabling OAuth 2.0 Authentication with Azure Active Directory (4) You will not be able to get the client secret after you leave the Certificates & secrets page.

3. Configure a web service application

To configure a web service application, you need to authorize your client application. To do this, perform the following steps:

  1. Open the Azure Active Directory service. In App registrations, open the registration of your web service application.

  2. Open the Expose an API page.

  3. Set the Application ID URI:

  4. When you authorize a client, you specify the scope to restrict client access. To define the scope, click Add a scope and configure it as you need:

    Enabling OAuth 2.0 Authentication with Azure Active Directory (6)

    Click the image to enlarge it.

  5. To authorize the client application, click Add a client application and specify the Application ID you got earlier:

    Enabling OAuth 2.0 Authentication with Azure Active Directory (7)

    Click the image to enlarge it.

4. Configure a request authentication

Now, you can configure authentication to a protected resource.

  1. In ReadyAPI, open a REST request.

  2. In the Auth panel, click Add Authorization to add a new authentication profile:

    Enabling OAuth 2.0 Authentication with Azure Active Directory (8)

    Click the image to enlarge it.

  3. Select the OAuth 2.0 (Azure)authentication type.

  4. ReadyAPI creates a profile and applies it to the request. Click Get Access Token to configure authentication and get an access token:

    Enabling OAuth 2.0 Authentication with Azure Active Directory (9)

    Click the image to enlarge it.

  5. Select Client Credentials Grant and fill in the required fields. To get the needed values, use data you got from Azure Active Directory earlier:

    Client identificationThe application ID of your client application. See the Overview page of your application in the Azure Active Directory.
    Client SecretThe client secret you created earlier. If you do not have it yet, create it on the Certificates & Secrets page of your application in the Azure Active Directory.
    ResourceThe Application ID URI of the protected web service. To get it, see the Overview page of your API application in the Azure Active Directory.
    Access Token URLThe URL to which ReadyAPI requests an access token. This URL looks as follows:

    https://login.microsoftonline.com/<your tenant id>/oauth2/token

    To get it, open your Azure Active Directory and click Endpoint.

    Show image

    Note:We omit some optional properties in this tutorial. To learn about them, see Client Credentials Grant.
  6. Click Get Access Token to retrieve the token:

    Enabling OAuth 2.0 Authentication with Azure Active Directory (11)

    Click the image to enlarge it.

Now, when you send the request, ReadyAPI sends the access token to authenticate it.

See Also

Enabling OAuth 2.0 Authentication
OAuth 2.0 Basics
OAuth 2.0 Grant Types
OpenID Connect

Enabling OAuth 2.0 Authentication with Azure Active Directory (2024)
Top Articles
Latest Posts
Article information

Author: The Hon. Margery Christiansen

Last Updated:

Views: 6583

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: The Hon. Margery Christiansen

Birthday: 2000-07-07

Address: 5050 Breitenberg Knoll, New Robert, MI 45409

Phone: +2556892639372

Job: Investor Mining Engineer

Hobby: Sketching, Cosplaying, Glassblowing, Genealogy, Crocheting, Archery, Skateboarding

Introduction: My name is The Hon. Margery Christiansen, I am a bright, adorable, precious, inexpensive, gorgeous, comfortable, happy person who loves writing and wants to share my knowledge and understanding with you.