Correct ADAL package for B2C - Xamarin PCL project

自古美人都是妖i 提交于 2019-12-09 03:25:21

问题


I have read several articles on adding Azure Active Directory sign-in functionality to Xamarin PCL projects (e.g. https://blog.xamarin.com/put-adal-xamarin-forms/) but I am still not able to make it work.

Can someone please clarifiy the correct ADAL package to use for Azure B2C AD(for Xamarin PCL project)?

Is it:

Microsoft.IdentityModel.Clients.ActiveDirectory

OR

Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory

Thanks!


回答1:


Thanks to @Kaush and @vibronet for pointing me in the right direction, saving a lot of time.

For anyone wanting to add B2C Sign-In & Sign-Up flows to a Xamarin Forms project - I was able to mash-up a solution for Android as follows:

  1. At all times change any reference to Microsoft.IdentityModel.Clients.ActiveDirectory to Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory

  2. Add the Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory package to all projects. If a compatibility error occurs in the PCL project then manually add a package reference using 'Add Reference' as described by @Kaush. I chose the 'portable-net45+win+wpa81' library.

  3. Implement the flows as described here: https://blog.xamarin.com/put-adal-xamarin-forms/

  4. Change the call to 'AcquireTokenAsync' to:

var result = await authContext.AcquireTokenAsync(new string[] { clientId }, null, clientId, new Uri(returnUri), platformParams, "{Policy_Name_Here}");

Notes:

  1. Ensure the format of the authority is 'https://login.microsoftonline.com/{Tenant_Name_Here}.onmicrosoft.com'

  2. This is experimental based on alpha code so expect it to change / break / evolve in the near future.




回答2:


Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory is the right package for B2C, but the Xamarin scenario wasn't one targeted by this preview. We'll be adding new platforms as we refresh the preview going forward.




回答3:


I would pay heed to what @vibronet says, but having said that (and to get you going), here's my screen shot of all the references that I use in the sample project you mentioned:


The ADAL package version I used was: 3.5.207081303-alpha (Prerelease), nuget did not add it to my PCL library, I ended up adding the reference explicitly via the 'Add Reference' and browsing to the package, maybe you could try the same.

Lastly, I had to add the extraQueryParameters as specified in here

Let me know how you go...



来源:https://stackoverflow.com/questions/33028388/correct-adal-package-for-b2c-xamarin-pcl-project

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