question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Microsoft.Identity.Client version 1.1.2-preview0008 doesn't work properly in Xamarin Forms

See original GitHub issue

Edit: 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:

https://login.live.com/err.srf?lc=2057#error=invalid_request&error_description=The+provided+value+for+the+input+parameter+‘redirect_uri’+is+not+valid.+The+expected+value+is+‘https://login.live.com/oauth20_desktop.srf’+or+a+URL+which+matches+the+redirect+URI+registered+for+this+client+application

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:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jpdc-developercommented, Feb 6, 2018

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.

0reactions
jennyf19commented, Feb 6, 2018

Thanks for the follow-up, @jpdc-developer - glad everything is working for you now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Microsoft.Identity.Client version 1.1.1-preview0040 doesn't ...
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...
Read more >
Xamarin Android code configuration and troubleshooting ...
General tips. Update the existing MSAL.NET NuGet package to the latest version of MSAL.NET. Verify that Xamarin. Forms is on the latest version....
Read more >
"Could not load file or assembly 'Microsoft.Identity.Client ...
Problem: So, the scenario, you have installed powershell 7.3.4 (or just 7), you have decided you want to use the newest version of ......
Read more >
Xamarin Forms Migration to MAUI - Build issues
I have migrated my Xamarin Forms app to a MAUI using upgrade assistant. First I converted the Solution then converted the Android and...
Read more >
Add authentication to your Xamarin.Forms app
Any tutorial that shows you how to enable authentication for an ASP.NET 6 service will work with Azure Mobile Apps. To enable Azure...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found