Login failed: Error: Redirect from microsoftaccount does not contain the required wams_state cookie. RRS feed

  • Question

  • I'm trying to authenticate to mobile services via microsoft account. I'm using node.js backend.

    I've set the client id, secret and packagesid to azure management site.The authentication seems to work via browser:

    https://<mobile_service> . Response is redirected to the ../done with the JWT token and userid etc.

    When I try to authenticate from Win 8.1 app i get the login prompt and when trying to login it takes a while and exception is thrown: Login failed: Error: Redirect from microsoftaccount does not contain the required wams_state cookie.

    Any idea how to fix this?

    Other authetication providers work fine.

    - Cougario

    • Edited by cougario Thursday, March 5, 2015 6:41 PM Added node.js backend comment
    Thursday, March 5, 2015 6:40 PM

All replies

  • Now i added 2nd parameter to LoginAsync call and the response is in the login UI: "We can't connect to the service you need right now. Check your network connection or try this again later."
    await mobileClient.LoginAsync(provider, true);

    - Cougario

    Thursday, March 5, 2015 8:53 PM
  • That first error implies that the Web Authentication Broker isn't returning cookies to Mobile Services during the redirect from Microsoft Account.

    The second error could be any number of things, but it generally means that the service returned an error code of some kind. It's possible that the redirect to Microsoft Account failed (often a redirect URI issue, so I would make sure those all match). This is possibly just masking the first error.

    Have you changed any configuration on the Web Authentication Broker? Also, have you tried this with more than one Microsoft account? Occasionally we see issues that are based on token length, which is impacted by length of the MSA email, etc. It's possible that this is what is resulting in the error (and it might explain the difference against the browser).

    If you have a network trace available, do you see a cookie being presented upon the redirect back to <a href="">https://<mobile_service> ?

    Any additional detail you can provide will be a big help

    Tuesday, March 10, 2015 2:58 AM
  • I've also been getting the above 2 errors mentioned after moving my project files to another pc. Everything was working fine on my laptop which unfortunately started having problems crashing every few minutes. So I had to switch to using my desktop pc. I downloaded Visual Studio 2015 Community and transferred over my project files. My UWP app works okay offline but when I tried to authenticate with Azure Mobile Services using my Microsoft account I would get no response after typing in my login credentials and clicking the Sign in button. If I clicked the Sign in button again, it would come back and say that the account or password is incorrect. If I re-input the password I would then get that first error about the redirect not containing the required wams_state cookie. So then I decided to migrate from Mobile Service to App Service to see if that would help. Then I started getting the second error before the Microsoft login prompt even comes up. Now I'm back to getting the first error. Not sure if that's because of anthing I did. I've tried changing different settings in the App Service. How would I do a network trace?
    Monday, March 21, 2016 10:17 PM
  • @AZ Apps,

    You were responding to a thread more than a year old.

    I'm investigating this issue right now, and pulled up this thread from a google search for "wams_state" cookie.  In the future, please make a new thread so we can be alerted to current issues faster. 

    I have this issue tracking the current problem:

    Friday, April 29, 2016 8:37 AM