Advertising sustains the DA. Ads are hidden for members. Join today

Drupal OAuth & OpenID Connect Login - OAuth2 Client SSO Login

Configure Microsoft Entra ID as OAuth Provider with Drupal as OAuth Client for SSO

Last updated on
22 April 2024

This document will help you configure Microsoft Entra ID or Azure AD as an OAuth provider making Drupal as an OAuth client. Following these steps will allow you to configure OAuth SSO between Microsoft Entra ID and your Drupal site such that your users will be able to log in to your Drupal site using their Microsoft Entra ID credentials.

We provide Drupal OAuth & OpenID Connect Login - OAuth2 Client SSO Login module which is compatible with Drupal 7, Drupal 8, Drupal 9, and Drupal 10.

 Download  Know more

You can check our module reviews and ratings here.

Prerequisite:

Setup Video: 

 Drupal Oauth Azure AD Youtube Video

Steps to configure Drupal as OAuth Client:

  • Once you have installed the module, go to the Configuration tab, and click on the miniOrange OAuth Client Configuration.

    Drupal OAuth OIDC SSO Login - Configuration -> Click on miniOrange OAuth Client Configuration

  • Provide the following information within the Configure OAuth tab:
    • Select Microsoft Entra ID (Azure AD) from the Select Application dropdown.
    • Copy the Callback/Redirect URL and keep it handy.

      If your provider only supports HTTPS Callback/Redirect URLs and you have an HTTP site, please make sure to enable the 'Enforce HTTPS Callback URL' checkbox at the bottom of the tab.

    • Enter the Application name in Display Name text field. For example, Azure.

    • Drupal OAuth OIDC SSO Login - Copy the Callback Redirect URL and keep it handy

Configure OAuth SSO Application in Microsoft Entra ID:

  • Login into your Microsoft Entra ID portal.
  • In the Azure services section, click on App registrations.

    Drupal-Azure-AD-Click-App-Registrations

  • Then, click on New registration.

    Microsoft Azure as OAuth/OpenID Provider - Click on New registration button

  • On the Register an Application page, enter the required information:
    • Name: Enter the Application Name, for example Drupal.
    • Supported account types: Select the 1st option - Accounts in this organizational directory only (Test only - Single tenant). If you are not sure what to choose, you can click on the Help me choose link.
    • Under the Redirect URI (optional) from the Select a platform dropdown select Web and paste the previously copied Callback URL under the text field next to the dropdown.

      Microsoft Azure - On the Register an Application, enter the Name and select Supported account types

  • Once done, click on the Register button.

Integrating Drupal with Microsoft Entra ID:

  • From the Microsoft Entra ID portal, copy the Application (client) ID.

    Microsoft Azure OAuth Single Sign-On - Copy the Application (client) ID

  • Navigate to the Drupal site and paste the copied Application(client) ID into the Client ID text field.

    Drupal OAuth & OpenId Connect Login - Paste it into the Client Id text field

  • Again, go back to the Microsoft Entra ID portal.
  • Click on Add a certificate or secret link.

    Microsoft Azure Portal - Click on Add a certificate or secret

  • Then, click on the New client secret button.
  • In the Add a client secret, enter the Description, and select duration of the certificate from the Expires dropdown. Click on the Add button.

    Microsoft Azure OAuth SSO Login - Click on New client secret button

  • Copy the Value from the Client secrets tab, this is your Client Secret key.

    Microsoft Azure OAuth SSO Login, Copy the Value from the Client Secrets tab

  • Then, navigate to the Drupal site and paste the copied Client secret value into the Client Secret text field.

    Drupal OAuth OpenId Connect SSO Login - Paste the copied value into the Client Secret text field

  • Go back to the Microsoft Entra ID portal and navigate to the Overview tab.

    Microsoft Azure Portal - Click on Overview

  • Under the Essentials section, copy the Directory (tenant) ID.

    Microsoft Azure Portal - Copy the Directory (tenant) ID

  • Navigate to the Drupal site and replace the copied Directory (tenant) ID with the {tenant-id} in the Authorization Endpoint and Access Token Endpoint text field. Once done, click on the Save Configuration button.

    Drupal OAuth/OIDC SSO Login - Replace it tenant-ID into the Authorize Endpoint and Access Token Endpoint

You can also refer to the Azure AD Endpoints and Scope from the table given below:

Scope OpenID
Authorize Endpoint: https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/authorize
Access Token Endpoint: https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token
Get User Info Endpoint: https://graph.microsoft.com/oidc/userinfo
  • The Send Client ID and Secret in checkbox allow you to specify whether the Client ID and Secret should be included in the header or the body of the Token Endpoint Request. If you're unsure which option to select, you can stick with the default settings.

    Drupal-Azure-AD-OAuth-Client-Select-Header-or-Body

Test Configuration of Drupal with Microsoft Entra ID :

  • After successfully saving the configurations, click on the Perform Test Configuration button to check the connection between Drupal and Azure AD.

    Drupal OAuth/OpenID Connect Login - Click on Perform Test Configuration

  • On a Test Configuration popup, if you don't have an active session in Microsoft Entra ID on the same browser, you will be asked to sign in to your Azure AD. After successfully logging into Microsoft Entra ID, you will be provided with a list of attributes that are received from the Azure AD.
  • Select the Email Attribute (The Attribute which contains the user's email. In our case it is ‘email’) from the dropdown menu and click on the Done button.

    Drupal OAuth Client SSO Login - Received Attribute from the Azure AD

  • Once clicked on the Done button, you will be redirected to the Attribute & Role Mapping tab. Now, you can also choose the Username Attribute from the dropdown and click on the Save Configuration button.

    Map the Attribute which received from the OAuth Server (Azure) with Drupal Attribute fields

Please note: Mapping the Email Attribute is mandatory for your login to work.

Congratulations! You have successfully configured Azure AD as OAuth Provider and Drupal as OAuth Client.

How to perform the SSO login?

  • Now, open a new browser/private window and go to your Drupal site login page.
  • Click on the Login using Azure link to initiate the SSO from Drupal.
  • If you want to add the SSO link to other pages as well, please follow the steps given in the image below:

    Drupal OAuth SSO Login - Configure OAuth - Scroll down and see the instruction to add login link to different pages in your Drupal site

Contact our 24*7 support team

Feel free to reach out to our Drupal experts if you need any sort of assistance in setting up OAuth2 Client SSO Login on your Drupal site.

 Get In Touch With Us Join Our Slack Channel

back to top Back to top