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

倾然丶 夕夏残阳落幕 提交于 2020-01-07 03:06:49

问题


I have used the following sample iOS project as provided here.

The sample is pretty straight forward and I can get ADAL to load the login view and request user authentication, all good.

Now, I intend to take it a little further by showing a login view with multiple identity providers (G+, Twitter, Fb, etc).

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:

<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 )

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?

Thanks in advance!


回答1:


I ended up resolving this myself by specifying the 'extraQueryParameters' in the authContext.AcquireTokenAsync() method. 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.

I now have multiple identity providers available for sign-in in my app, based on the policy that I've setup in Azure portal. Hooray! :)

HTH...



来源:https://stackoverflow.com/questions/32949988/azure-ad-b2c-specify-multiple-identity-providers-in-xamarin-forms-ios-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!