适用于iOS的Azure AD B2C自定义本机登录屏幕

时间:2019-01-09 07:36:15

标签: azure-ad-b2c

如何实现连接到Microsoft Azure AD B2C的本机自定义登录(和注册)屏幕?

这是设置:

  • 我有一个使用Xcode / Swift开发的移动应用程序...
  • ...需要再次注册和登录用户(新)Azure Active Directory B2C(请注意此处的B2C,因为Microsoft还提供了其他AD解决方案)

enter image description here

Microsoft提供的解决方案可以在这里找到:https://github.com/Azure-Samples/active-directory-b2c-ios-swift-native-msal。但这会打开一个safari窗口,这不是我想要的用户体验:

enter image description here

相反,我想用自己的布局和设计来构建本机登录屏幕(UIViewController),但仍想使用Azure Active Directory B2C。

这怎么办?

1 个答案:

答案 0 :(得分:0)

For sign-in, you can implement a native page that integrates with a resource owner password credentials policy in the Azure AD B2C tenant, which will enable a user's credentials to be POSTed to the Azure AD B2C tenant for validation:

POST /tfp/yourtenant.onmicrosoft.com/B2C_1_ROPC_Auth/oauth2/v2.0/token HTTP/1.1
Host: yourtenant.b2clogin.com
Content-Type: application/x-www-form-urlencoded

grant_type=password&
username=leadiocl%40trashmail.ws&
password=Passxword1&
scope=openid+bef22d56-552f-4a5b-b90a-1988a7d634ce+offline_access
client_id=bef22d56-552f-4a5b-b90a-1988a7d634ce&
response_type=token+id_token

For sign-up, a client credential is required to request an access token for the Azure AD Graph API to create an Azure AD B2C user, so if you are wanting to implement a native page then you will have to consider also implementing a backend/proxy API that protects the client credential.