向 Azure Active Directory B2C 租户添加本机客户端应用程序Add a native client application to your Azure Active Directory B2C tenant

需要先在租户中注册本机客户端资源,然后应用程序才能与 Azure Active Directory B2C 通信。Native client resources need to be registered in your tenant before your application can communicate with Azure Active Directory B2C.

若要在 Azure AD B2C 租户中注册应用程序,可以使用当前“应用程序”体验 。To register an application in your Azure AD B2C tenant, you can use the current Applications experience.

  1. 登录到 Azure 门户Sign in to the Azure portal.
  2. 在顶部菜单中选择“目录 + 订阅” 筛选器,然后选择包含Azure AD B2C 租户的目录。Select the Directory + subscription filter in the top menu, and then select the directory that contains your Azure AD B2C tenant.
  3. 在左侧菜单中,选择“Azure AD B2C” 。In the left menu, select Azure AD B2C. 或者,选择“所有服务” 并搜索并选择“Azure AD B2C” 。Or, select All services and search for and select Azure AD B2C.
  4. 选择“应用程序”,然后选择“添加” 。Select Applications, and then select Add.
  5. 输入应用程序的名称。Enter a name for the application. 例如,“nativeapp1” 。For example, nativeapp1.
  6. 对于本机客户端,选择“是” 。For Native client, select Yes.
  7. 输入使用唯一方案的自定义重定向 URIEnter a Custom Redirect URI with a unique scheme. 例如,com.onmicrosoft.contosob2c.exampleapp://oauth/redirectFor example, com.onmicrosoft.contosob2c.exampleapp://oauth/redirect. 选择重定向 URI 时,有两个重要的注意事项:There are two important considerations when choosing a redirect URI:
    • 唯一:每个应用程序的重定向 URI 的方案必须是唯一的。Unique: The scheme of the redirect URI must be unique for every application. 在示例 com.onmicrosoft.contosob2c.exampleapp://oauth/redirect 中,com.onmicrosoft.contosob2c.exampleapp 为方案。In the example com.onmicrosoft.contosob2c.exampleapp://oauth/redirect, com.onmicrosoft.contosob2c.exampleapp is the scheme. 应遵循此模式。This pattern should be followed. 如果两个应用程序共享同一方案,则用户应选择一个应用程序。If two applications share the same scheme, the user is given a choice to choose an application. 如果用户选择不正确,登录会失败。If the user chooses incorrectly, the sign-in fails.
    • 完整:重定向 URI 必须同时包含方案和路径。Complete: The redirect URI must have a both a scheme and a path. 路径必须在域之后包含至少一个正斜杠。The path must contain at least one forward slash after the domain. 例如,//oauth/ 有效,而 //oauth 会失败。For example, //oauth/ works while //oauth fails. 不要在 URI 中包含特殊字符,例如,下划线。Don't include special characters in the URI, for example, underscores.
  8. 选择“创建” 。Select Create.