| title | Set up sign-up and sign-in with Mobile ID |
|---|---|
| titleSuffix | Azure AD B2C |
| description | Provide sign-up and sign-in to customers with Mobile ID in your applications using Azure Active Directory B2C. |
| author | garrodonnell |
| manager | celestedg |
| ms.service | azure-active-directory |
| ms.topic | how-to |
| ms.date | 04/08/2022 |
| ms.author | godonnell |
| ms.subservice | b2c |
| zone_pivot_groups | b2c-policy-type |
[!INCLUDE active-directory-b2c-end-of-sale-notice-b]
[!INCLUDE active-directory-b2c-choose-user-flow-or-custom-policy]
In this article, you learn how to provide sign-up and sign-in to customers with Mobile ID in your applications using Azure Active Directory B2C (Azure AD B2C). The Mobile ID solution protects access to your company data and applications with a comprehensive end-to- end solution for a strong multi-factor authentication (MFA). You add the Mobile ID to your user flows or custom policy using OpenID Connect protocol.
[!INCLUDE active-directory-b2c-customization-prerequisites]
To enable sign-in for users with Mobile ID in Azure AD B2C, you need to create an application. To create Mobile ID application, follow these steps:
-
Contact Mobile ID support.
-
Provide the Mobile ID the information about your Azure AD B2C tenant:
Key Note Redirect URI Provide the https://your-tenant-name.b2clogin.com/your-tenant-name.onmicrosoft.com/oauth2/authrespURI. If you use a custom domain, enterhttps://your-domain-name/your-tenant-name.onmicrosoft.com/oauth2/authresp. Replaceyour-tenant-namewith the name of your tenant, andyour-domain-namewith your custom domain.Token endpoint authentication method client_secret_post -
After the app is registered, the following information will be provided by the Mobile ID. Use this information to configure your user flow, or custom policy.
Key Note Client ID The Mobile ID client ID. For example, 00001111-aaaa-2222-bbbb-3333cccc4444. Client Secret The Mobile ID client secret.
::: zone pivot="b2c-user-flow"
-
If you have access to multiple tenants, select the Settings icon in the top menu to switch to your Azure AD B2C tenant from the Directories + subscriptions menu.
-
Choose All services in the top-left corner of the Azure portal, and then search for and select Azure AD B2C.
-
Select Identity providers, and then select New OpenID Connect provider.
-
Enter a Name. For example, enter Mobile ID.
-
For Metadata url, enter the URL Mobile ID OpenId well-known configuration endpoint. For example:
https://openid.mobileid.ch/.well-known/openid-configuration -
For Client ID, enter the Mobile ID Client ID.
-
For Client secret, enter the Mobile ID client secret.
-
For the Scope, enter the
openid, profile, phone, mid_profile. -
Leave the default values for Response type (
code), and Response mode (form_post). -
(Optional) For the Domain hint, enter
mobileid.ch. For more information, see Set up direct sign-in using Azure Active Directory B2C. -
Under Identity provider claims mapping, select the following claims:
- User ID: sub
- Display name: name
-
Select Save.
At this point, the Mobile ID identity provider has been set up, but it's not yet available in any of the sign-in pages. To add the Mobile ID identity provider to a user flow:
- In your Azure AD B2C tenant, select User flows.
- Select the user flow that you want to add the Mobile ID identity provider.
- Under the Social identity providers, select Mobile ID.
- Select Save.
- To test your policy, select Run user flow.
- For Application, select the web application named testapp1 that you previously registered. The Reply URL should show
https://jwt.ms. - Select the Run user flow button.
- From the sign-up or sign-in page, select Mobile ID to sign in with Mobile ID.
If the sign-in process is successful, your browser is redirected to https://jwt.ms, which displays the contents of the token returned by Azure AD B2C.
::: zone-end
::: zone pivot="b2c-custom-policy"
You need to store the client secret that you received from Mobile ID in your Azure AD B2C tenant.
- Sign in to the Azure portal.
- Make sure you're using the directory that contains your Azure AD B2C tenant. Select the Directory + subscription filter in the top menu and choose the directory that contains your tenant.
- Choose All services in the top-left corner of the Azure portal, and then search for and select Azure AD B2C.
- On the Overview page, select Identity Experience Framework.
- Select Policy Keys and then select Add.
- For Options, choose
Manual. - Enter a Name for the policy key. For example,
Mobile IDSecret. The prefixB2C_1A_is added automatically to the name of your key. - In Secret, enter your Mobile ID client secret.
- For Key usage, select
Signature. - Select Create.
To enable users to sign in using a Mobile ID, you need to define the Mobile ID as a claims provider that Azure AD B2C can communicate with through an endpoint. The endpoint provides a set of claims that are used by Azure AD B2C to verify that a specific user has authenticated.
You can define a Mobile ID as a claims provider by adding it to the ClaimsProviders element in the extension file of your policy.
-
Open the TrustFrameworkExtensions.xml.
-
Find the ClaimsProviders element. If it doesn't exist, add it under the root element.
-
Add a new ClaimsProvider as follows:
<ClaimsProvider> <Domain>mobileid.ch</Domain> <DisplayName>Mobile-ID</DisplayName> <TechnicalProfiles> <TechnicalProfile Id="MobileID-OAuth2"> <DisplayName>Mobile-ID</DisplayName> <Protocol Name="OAuth2" /> <Metadata> <Item Key="ProviderName">Mobile-ID</Item> <Item Key="authorization_endpoint">https://m.mobileid.ch/oidc/authorize</Item> <Item Key="AccessTokenEndpoint">https://openid.mobileid.ch/token</Item> <Item Key="ClaimsEndpoint">https://openid.mobileid.ch/userinfo</Item> <Item Key="scope">openid, profile, phone, mid_profile</Item> <Item Key="HttpBinding">POST</Item> <Item Key="UsePolicyInRedirectUri">false</Item> <Item Key="token_endpoint_auth_method">client_secret_post</Item> <Item Key="BearerTokenTransmissionMethod">AuthorizationHeader</Item> <Item Key="client_id">Your application ID</Item> </Metadata> <CryptographicKeys> <Key Id="client_secret" StorageReferenceId="B2C_1A_MobileIdSecret" /> </CryptographicKeys> <OutputClaims> <OutputClaim ClaimTypeReferenceId="issuerUserId" PartnerClaimType="sub"/> <OutputClaim ClaimTypeReferenceId="displayName" PartnerClaimType="name"/> <OutputClaim ClaimTypeReferenceId="identityProvider" DefaultValue="mobileid.ch" /> <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="socialIdpAuthentication" /> </OutputClaims> <OutputClaimsTransformations> <OutputClaimsTransformation ReferenceId="CreateRandomUPNUserName" /> <OutputClaimsTransformation ReferenceId="CreateUserPrincipalName" /> <OutputClaimsTransformation ReferenceId="CreateAlternativeSecurityId" /> <OutputClaimsTransformation ReferenceId="CreateSubjectClaimFromAlternativeSecurityId" /> </OutputClaimsTransformations> <UseTechnicalProfileForSessionManagement ReferenceId="SM-SocialLogin" /> </TechnicalProfile> </TechnicalProfiles> </ClaimsProvider>
-
Set client_id to the Mobile ID client ID.
-
Save the file.
[!INCLUDE active-directory-b2c-add-identity-provider-to-user-journey]
<OrchestrationStep Order="1" Type="CombinedSignInAndSignUp" ContentDefinitionReferenceId="api.signuporsignin">
<ClaimsProviderSelections>
...
<ClaimsProviderSelection TargetClaimsExchangeId="MobileIDExchange" />
</ClaimsProviderSelections>
...
</OrchestrationStep>
<OrchestrationStep Order="2" Type="ClaimsExchange">
...
<ClaimsExchanges>
<ClaimsExchange Id="MobileIDExchange" TechnicalProfileReferenceId="MobileID-OAuth2" />
</ClaimsExchanges>
</OrchestrationStep>[!INCLUDE active-directory-b2c-configure-relying-party-policy]
- Select your relying party policy, for example
B2C_1A_signup_signin. - For Application, select a web application that you previously registered. The Reply URL should show
https://jwt.ms. - Select the Run now button.
- From the sign-up or sign-in page, select Mobile ID to sign in with Mobile ID.
If the sign-in process is successful, your browser is redirected to https://jwt.ms, which displays the contents of the token returned by Azure AD B2C.
::: zone-end
Learn how to pass Mobile ID token to your application.