Microsoft.Identity.Client version 1.1.2-preview0008 doesn't work properly in Xamarin Forms
See original GitHub issueEdit: I’ve followed this wiki page so that my nuget packages are up to date. I am still observing the same issue.
I used Microsoft.Identity.Client version 1.0.303282006 for authentication in my Xamarin App but I have updated it to version 1.1.2-preview0008.
It behaves incorrectly now. After refactoring the code to work with version 1.1.2-preview0008, the app builds, but when the line of code for getting the token is run, AcquireTokenAsync(Scopes)
, this exception is raised:
"Method 'Microsoft.Identity.Client.PublicClientApplication.AcquireTokenAsync' not found."
I tried other signatures of the same method. Right now, I’m using _pca.AcquireTokenAsync(Scopes, uIParent)
. I can get uIParent from the Android App, but it doesn’t work 100%. It opens a login dialog, allows me to enter my username, then it shows a page saying “We’re unable to complete your request.”
I had a look at the url of this page and it indicates that there’s been an error:
I’ve tried other similar signatures of the same method and it always fails in the part where it’s supposed to ask me for my password. It seems like my Microsoft.Identity.Client nuget package can be found but it’s not being utilised properly.
From the looks of things, it seems like the preview version (1.1.2-preview0008) of Microsoft.Identity.Client isn’t working properly on the Xamarin App. However, I tried making a WinForms app and it works properly there so I’m not sure what caused this issue.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
You’re right @jennyf19. I needed to set the redirect URI and use
AcquireTokenAsync(IEnumerable<string> scopes, UIParent parent)
. I also followed the way the Xamarin Forms Sample App set things up so that I had to add more setup code in the Android Manifest.I also added a custom redirect URI in the Application Registration Portal in the format
msal<clientId>://auth
.Thanks for the follow-up, @jpdc-developer - glad everything is working for you now.