MVC5 + Microsoft account (Live ID) + IIS = redirect_uri is not valid

I am putting together a simple POC for a client who wants to use a LiveId (now a Microsoft or MSA account) to log in. I've done this with FaceBook, Google and Twitter, and they all walked the park. For whatever reason, MSA is the royal PITA.

I created an MVC5 app using Visual Studio 2015. I went to the MSA dev center to build my app and get the client id and secret. The redirect url I am using is http://localtest.me/membersweb/signin-microsoft The Client ID and Secret goes to Start.Auth.cs as usual.

I have installed IIS and have my application in a virtual directory. When I launch my application, it appears as usual. I click Login and it goes to the login page as expected and the Microsoft button appears in the right column as expected. When you click the Microsoft button, you are redirected to the MSA login page. B / c I'm already signed. I must be sent to a login page where I grant my permission to access my information. Instead, I ended up on an error page. The title says "We are unable to fulfill your request," and the rest of the message reads, "Microsoft account is having technical problems. Please try again later." Pretty useless. The url is a little more helpful with the following error message: invalid_request &error_description = + + + + + + + + + + + + + + + + + + + + + + + + + + + + <https://login.live.com/oauth20_desktop.srf '+ or + a + Url + which + matches + buttons + redirect + URI + registered + for + this + client + app.

This is not rocket science. I do this with FaceBook all the time. What blanks am I doing wrong?

No other coding, tuning, or tuning has been done.

TIA

+3


source to share


1 answer


  • Go to https://account.live.com/developers/applications
  • Select your application
  • Go to "Edit Settings"
  • Go to API settings
  • Change redirect urls: add " / signin-microsoft " to the end of your redirect_uri
  • Go to your code and set the same redirect_uri for the API call
  • Go drink a beer or two or more

This worked for me :)



PS: If it still doesn't work, try adding " / Account / ExternalLoginCallback " at the end of your redirect_uri, but this is not confirmed as a working solution

For more information here: http://www.benday.com/2014/02/25/walkthrough-asp-net-mvc-identity-with-microsoft-account-authentication/

+4


source







All Articles