Connect Your App to Microsoft Azure Active Directory
You can integrate with Microsoft Azure Active Directory (AD) if you want to let users:
- From within your company use your application from an Azure AD controlled by you or your organization.
- From other companies' Azure ADs use your application. (We recommend that you configure external directories as different connections.)
Prerequisites
- Register your app with Auth0
- Select an appropriate Application Type.
- Add an Allowed Callback URL of
https://YOUR_APP/callback
. - Make sure your Application's Grant Types include the appropriate flows.
- Have an Azure account. If you don't, you can sign up for free.
- Have an Azure AD directory. If you don't, you can create one by following Microsoft's Quickstart: Create a new tenant in Azure Active Directory - Create a new tenant for your organization.
Steps
To connect your application to Azure AD, you must:
- Register your app with Azure AD.
- Create an enterprise connection in Auth0.
- Enable the enterprise connection for your Auth0 Application.
- Test the connection.
Register your app with Azure AD
To register your app with Azure AD, see Microsoft's Quickstart: Register an application with the Microsoft identity platform.
During registration, configure the following settings:
Option | Setting |
---|---|
Supported account types | To allow users from external organizations (like other Azure AD directories) choose the appropriate multitenant option. Multitenant options include the following: Accounts in any organizational directory (Any Azure AD directory - Multitenant). |
Redirect URI | Enter your callback URL: https://YOUR_DOMAIN/login/callback . |
Find your Auth0 domain name for redirects
If your Auth0 domain name is not shown above and you are not using our custom domains feature, your domain name is your tenant name, plus .auth0.com
. For example, if your tenant name were exampleco-enterprises
, your Auth0 domain name would be exampleco-enterprises.auth0.com
and your redirect URI would be https://exampleco-enterprises.auth0.com/login/callback
.
If you are using custom domains, your redirect URI will have the following format:
https://<YOUR CUSTOM DOMAIN>/login/callback
During this process, Microsoft generates an Application (client) ID for your application; you can find this on the app's Overview screen. Make note of this value.
Create a client secret
To create a client secret, see Microsoft's Quickstart: Configure a client application to access web APIs - Add Credentials to your web application.
Once generated, make note of this value.
Add permissions
To add permissions, see Microsoft's Quickstart: Configure a client application to access web APIs - Add permissions to access web APIs.
You will need to configure permissions for the Microsoft Graph API.
While setting up your permissions, configure the following settings:
Field | Description |
---|---|
Delegated permissions | Required. |
Users > User.Read | So your app can sign in users and read the signed-in users' profiles. |
Directory > Directory.Read.All | So your app can read directory data on the signed-in user's behalf. |
If you want to enable extended attributes (such as Extended Profile or Security Groups), then you also must configure the following settings:
Field | Description |
---|---|
Delegated permissions | Under Directory, select Directory.AccessAsUser.All so your app can access the directory as the signed-in user. |
Application Permissions | Under Directory, select Directory.Read.All so your app can read directory data. |
Create an enterprise connection in Auth0
Create and configure an Azure AD Enterprise Connection in Auth0. Make sure you have the Application (client) ID and the Client secret generated when you set up your app in the Microsoft Azure portal.
- Navigate to the Connections > Enterprise page in the Auth0 Dashboard, and click the
+
next to Microsoft Azure AD.
- Enter general information for your connection.
Field | Description |
---|---|
Connection name | Logical identifier for your connection; it must be unique for your tenant. Once set, this name can't be changed. |
Microsoft Azure AD Domain | Your Azure AD domain name. You can find this on your Azure AD directory's overview page in the Microsoft Azure portal. |
- Enter credentials, select attributes, and configure advanced settings for your connection.
Field | Description |
---|---|
Client ID | Unique identifier for your registered Azure AD application. Enter the saved value of the Application (client) ID for the app you just registered in Azure AD. |
Client Secret | String used to gain access to your registered Azure AD application. Enter the saved value of the Client secret for the app you just registered in Azure AD. |
Use common endpoint | (Optional) When enabled, your application will dynamically accept users from new directories. Typically enabled if you selected a multitenant option for Supported account types for the application you just registered in Azure AD. When enabled, Auth0 will redirect users to Azure's common login endpoint, and Azure will perform Home Realm Discovery based on the domain of the user's email address. |
Identity API | API used by Auth0 to interact with Azure AD endpoints. Learn about the differences in behavior in Microsoft's Why update to Microsoft identity platform (v2.0) doc. |
Attributes | Basic attributes for the signed-in user that your app can access. Indicates how much information you want stored in the Auth0 User Profile. |
Extended Attributes (optional) | Extended attributes for the signed-in user that your app can access. |
Auth0 APIs (optional) | When selected, indicates that we require the ability to make calls to the Azure AD API, which allows us to search for users in the Azure AD Graph even if they never logged in to Auth0. This is required in some cases, since no feature parity exists between the Azure AD API v1 and Microsoft Identity Plaform v2, but it will be eliminated when the Auth0 Management API v1 is shut down after July 6, 2020. |
Sync user profile attributes at each login | When enabled, Auth0 automatically syncs user profile data with each user login, thereby ensuring that changes made in the connection source are automatically updated in Auth0. |
-
Click Create.
-
On the Login Experience tab you can configure how users log in with this connection.
Field | Description |
---|---|
Identity Provider domains | A comma-separated list of the domains that can be authenticated in the Identify Provider. This is only applicable when using Identifier First authentication in the Universal Login Experience. |
Add button (Optional) | Display a button for this connection in the login page. |
Button display name (Optional) | Text used to customize the login button for new Universal Login. When set the button reads: "Continue with {Button display name}". |
Button logo URL (Optional) | URL of image used to customize the login button for new Universal Login. When set, the Universal Login login button displays the image as a 20px by 20px square. |
-
If you have appropriate Azure AD administrative permissions to give consent to the application so users can log in, then click Continue.
You will be asked to log in to your Azure AD account and give consent. Otherwise, provide the given URL to your administrator so that they can give consent.
Enable the enterprise connection for your Auth0 application
To use your new Azure AD enterprise connection, you must first enable the connection for your Auth0 Applications.
Test the connection
Now you're ready to test your connection.
Troubleshooting
Here are some troubleshooting tips:
I registered my application with Azure AD, but when I go back to my Azure Active Directory App registrations, I can't see my application.
You may have accidentally registered your app in the wrong Azure AD directory (or not have created an Azure AD directory at all before registering your app). It's likely easiest to re-register your app in Azure AD. Make sure you are in the correct directory when you register the app. If you need to create an Azure AD directory, follow Microsoft's Quickstart: Create a new tenant in Azure Active Directory - Create a new tenant for your organization.
I receive the following error message: "Access cannot be granted to this service because the service listing is not properly configured by the publisher".
To resolve this, try changing the Supported account types for your registered Azure AD app. Make sure you have chosen an appropriate multitenant option in the Azure AD app's Authentication settings. Multitenant options include the following: Accounts in any organizational directory (Any Azure AD directory - Multitenant).
When users try to log in, we receive the following error message: "invalid_request; failed to obtain access token".
The most likely reason for this error is an invalid or expired Azure AD Client secret. To resolve this, generate a new Client secret for your app in Azure AD, then update the Client Secret in the enterprise connection configured with Auth0.
Signing Key Rollover in Azure AD
Signing keys are used by the identity provider to sign the authentication token it issues, and by the consumer application (Auth0 in this case) to validate the authenticity of the generated token.
For security purposes, Azure AD’s signing key rolls on a periodic basis. If this happens, you do not need to take any action. Auth0 will use the new key automatically.
Next Steps
Remove unverified label
If you're using a custom domain, the application consent prompt for Azure AD login may label your domain as "unverified". To remove the unverified label:
- Verify the domain for the Auth0 application: Add your custom domain name using the Azure Active Directory portal
- Assign the verified domain to the Auth0 application: How to: Configure an application's publisher domain