简体   繁体   English

Azure AD B2C在Xamarin.Forms iOS应用中指定多个身份提供程序

[英]Azure AD B2C Specify multiple Identity Providers in Xamarin.Forms iOS app

I have used the following sample iOS project as provided here . 我使用了此处提供的以下示例iOS项目。

The sample is pretty straight forward and I can get ADAL to load the login view and request user authentication, all good. 该示例非常简单,我可以让ADAL加载登录视图并请求用户身份验证,一切都很好。

Now, I intend to take it a little further by showing a login view with multiple identity providers (G+, Twitter, Fb, etc). 现在,我打算通过显示具有多个身份提供者(G +,Twitter,Fb等)的登录视图来进一步介绍它。

In a web application, I can see multiple identity providers when I request for authentication as we can specify the policies in the web.config like so: 在Web应用程序中,当我请求身份验证时,我可以看到多个身份提供者,因为我们可以在web.config中指定策略,如下所示:

<add key="ida:Tenant" value="sometenant.onmicrosoft.com" />
<add key="ida:ClientId" value="clientidguid" />
<add key="ida:ClientSecret" value="clientsecret" />
<add key="ida:AadInstance" value="https://login.microsoftonline.com/{0}{1}{2}" />
<add key="ida:RedirectUri" value="https://localhost:44321/" />
<add key="ida:SignUpPolicyId" value="b2c_1_xyz_policy" />
<add key="ida:SignInPolicyId" value="b2c_1_xyz_sign_in" />
<add key="ida:UserProfilePolicyId" value="b2c_1_xyz_editing" />

I have the same redirect uri that I've used in the app (I have also tried to use the redirect uri for Native client with no luck ) 我已经在应用程序中使用了相同的重定向uri(我也尝试过将uri重定向用于本机客户端,但没有运气)

I was wondering, how do I specify policies in a Xamarin forms project so that I can see multiple identity providers for user sign-in in my iOS app? 我想知道如何在Xamarin表单项目中指定策略,以便可以在iOS应用中看到多个身份提供者以用于用户登录?

Thanks in advance! 提前致谢!

I ended up resolving this myself by specifying the 'extraQueryParameters' in the authContext.AcquireTokenAsync() method. 最后,我自己通过在authContext.AcquireTokenAsync()方法中指定“ extraQueryParameters”来解决此问题。 This post helped a great deal to come up with the required solution. 这篇文章对提出所需的解决方案很有帮助。

var authResult = await authContext.AcquireTokenAsync(resource, clientId, new Uri(returnUri), new PlatformParameters(UIApplication.SharedApplication.KeyWindow.RootViewController), UserIdentifier.AnyUser, "&scope=openid&p=B2C_1_xyz_sign_in");

The 'scope' was a required param and the 'p' param specifies the policy to use. 'scope'是必需的参数,'p'参数指定要使用的策略。

I now have multiple identity providers available for sign-in in my app, based on the policy that I've setup in Azure portal. 现在,根据我在Azure门户中设置的策略,我的应用程序中可以使用多个身份提供程序进行登录。 Hooray! 万岁! :) :)

HTH... 嗯...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM