title | titleSuffix | description | services | author | ms.service | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|
Authorize developer accounts by using Azure Active Directory B2C |
Azure API Management |
Learn how to authorize users of the developer portal in Azure API Management by using Azure Active Directory B2C |
api-management |
dlepow |
api-management |
how-to |
09/28/2021 |
danlep |
Azure Active Directory B2C is a cloud identity management solution for consumer-facing web and mobile applications. You can use it to manage access to your API Management developer portal.
In this tutorial, you'll learn the configuration required in your API Management service to integrate with Azure Active Directory B2C. As noted later in this article, if you are using the deprecated legacy developer portal, some steps will differ.
For information about enabling access to the developer portal by using classic Azure Active Directory, see How to authorize developer accounts using Azure Active Directory.
- An Azure Active Directory B2C tenant in which to create an application. For more information, see Azure Active Directory B2C overview.
- An API Management instance. If you don't already have one, create an Azure API Management instance.
[!INCLUDE premium-dev-standard.md]
In this section, you'll create a user flow in your Azure Active Directory B2C tenant containing both sign up and sign in policies. For detailed steps, see Create user flows and custom policies in Azure Active Directory B2C.
- In the Azure portal, access your Azure Active Directory B2C tenant.
- Under Policies, select User flows > + New user flow.
- On the Create a user flow page, select the Sign up and sign in user flow.
- Provide the following information:
- Enter a unique name for the user flow.
- In Identity providers, select Email signup.
- In User attributes and token claims, select the attributes and claims needed for the API Management developer portal (not needed for the legacy developer portal).
- Attributes: Given Name, Surname
- Claims: Email Addresses, Given Name, Surname, User’s ObjectID
- Select Create.
-
In a separate Azure portal tab, navigate to your API Management instance.
-
Under Developer portal, select Identities > + Add.
-
In the Add identity provider page, select Azure Active Directory B2C.
-
In the Add identity provider window, copy the Redirect URL.
:::image type="content" source="media/api-management-howto-aad-b2c/b2c-identity-provider-redirect-url.png" alt-text="Copy redirect URL":::
-
Return to the browser tab for your Azure Active Directory B2C tenant in the Azure portal. Select App registrations > + New registration.
-
In the Register an application page, enter your application's registration information.
- In the Name section, enter an application name of your choosing.
- In the Supported account types section, select Accounts in any identity provider or organizational directory (for authenticating users with user flows). For more information, see Register an application.
- In Redirect URI, enter the Redirect URL your copied from your API Management instance.
- In Permissions, select Grant admin consent to openid and offline_access permissions.
- Select Register to create the application.
:::image type="content" source="media/api-management-howto-aad-b2c/b2c-app-registration.png" alt-text="Register a new application":::
-
On the app Overview page, find the Application (client) ID and copy the value to the clipboard.
:::image type="content" source="media/api-management-howto-aad-b2c/b2c-app-id.png" alt-text="Application ID":::
-
Switch back to the API Management Add identity provider page and paste the ID into the Client Id text box.
-
Switch back to the B2C app registration. Select Certificates & secrets > + New client secret. :::image type="content" source="media/api-management-howto-aad-b2c/generate-app-key.png" alt-text="Create client secret":::
- In the Add a client secret page, enter a Description and select Add.
- Record the key in a safe location. This secret value is never displayed again after you leave this page.
-
Switch back to the API Management Add identity provider page, and paste the key into the Client secret text box.
-
Switch back to the B2C app registration. In the left menu, under Manage, select Authentication.
- Under Implicit grant and hybrid flows, select both the Access tokens and ID tokens check boxes.
- Select Save.
-
Switch back in the API Management Add identity provider page.
-
In Signin tenant, specify the domain name of the Azure Active Directory B2C tenant.
-
The Authority field lets you control the Azure Active Directory B2C login URL to use. Set the value to <your_b2c_tenant_name>.b2clogin.com.
-
Specify the Signup Policy and Signin Policy from the B2C tenant policies.
-
Optionally provide the Profile Editing Policy and Password Reset Policy.
:::image type="content" source="media/api-management-howto-aad-b2c/add-identity-provider.png" alt-text="Active Directory B2c identity provider configuration":::
-
-
After you've specified the desired configuration, select Add.
After the changes are saved, developers will be able to create new accounts and sign in to the developer portal by using Azure Active Directory B2C.
Important
You need to republish the developer portal when you create or update Azure Active Directory B2C configuration settings for the changes to take effect.
In the developer portal, sign-in with Azure Active Directory B2C is possible with the Sign-in button: OAuth widget. The widget is already included on the sign-in page of the default developer portal content.
-
To sign in by using Azure Active Directory B2C, open a new browser window and go to the developer portal. Select Sign in.
-
On the Sign in page, select Azure Active Directory B2C.
:::image type="content" source="media/api-management-howto-aad-b2c/developer-portal-sign-in.png" alt-text="Sign in to developer portal":::
-
You're redirected to the signup policy that you configured in the previous section. Choose to sign up by using your email address in the Active Directory B2C tenant
When the signup is complete, you're redirected back to the developer portal. You're now signed in to the developer portal for your API Management service instance.
:::image type="content" source="media/api-management-howto-aad-b2c/developer-portal-home.png" alt-text="Sign in to developer portal complete":::
Although a new account is automatically created whenever a new user signs in with Azure Active Directory B2C, you may consider adding the same widget to the signup page.
The Sign-up form: OAuth widget represents a form used for signing up with OAuth.
[!INCLUDE api-management-portal-legacy.md]
Note
To properly integrate B2C with the legacy developer portal, use standard v1 user flows, in combination with enabling password reset before signing up/signing into a developer account using Azure Active Directory B2C.
-
Open a new browser window and go to the legacy developer portal. Click the Sign up button.
:::image type="content" source="media/api-management-howto-aad-b2c/b2c-dev-portal.png" alt-text="Sign up in legacy developer portal":::
-
Choose to sign up with Azure Active Directory B2C.
:::image type="content" source="media/api-management-howto-aad-b2c/b2c-dev-portal-b2c-button.png" alt-text="Sign up with Azure Active Directory B2C":::
-
You're redirected to the signup policy you configured in the previous section. Choose to sign up by using your email address or one of your existing social accounts.
[!NOTE] If Azure Active Directory B2C is the only option enabled on the Identities tab in the Azure portal, you'll be redirected to the signup policy directly.
:::image type="content" source="media/api-management-howto-aad-b2c/b2c-dev-portal-b2c-options.png" alt-text="Sign up options in legacy developer portal":::
When the signup is complete, you're redirected back to the developer portal. You're now signed in to the developer portal for your API Management service instance.
- Azure Active Directory B2C overview
- Azure Active Directory B2C: Extensible policy framework
- Use a Microsoft account as an identity provider in Azure Active Directory B2C
- Use a Google account as an identity provider in Azure Active Directory B2C
- Use a LinkedIn account as an identity provider in Azure Active Directory B2C
- Use a Facebook account as an identity provider in Azure Active Directory B2C