简体   繁体   中英

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

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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