Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to obtain Access Token from WindowsLive or response was not HTTP status 200 OK #213

Open
zahidmadeel opened this issue Jun 22, 2016 · 11 comments
Assignees

Comments

@zahidmadeel
Copy link

Hi,

I have been trying to integrate with windows live using your API. I have tried version 0.6 and 0.7 of your library but I get the following exception

SimpleAuthentication.Core.Exceptions.AuthenticationException: Message: Failed to obtain an Access Token from WindowsLive OR the the response was not an HTTP Status 200 OK. Response Status: BadRequest. Response Description: Bad Request. Error Content: {"error":"invalid_request","error_description":"The provided request must be sent using the HTTP 'POST' method."}. Error Message: --no error exception--.
I get this error on the following line of code
client = authProvider.AuthenticateClient(querystringParameters, existingState, callBackUri);
It seems to me that your API is using get request to obtain access token from windows live and hence it is failing
Regards
Adeel

@PureKrome
Copy link
Member

Hmm. I wonder if it needs to be updated (our code). i'll have a play now and see what happens.

@PureKrome PureKrome added the bug label Jun 22, 2016
@PureKrome PureKrome self-assigned this Jun 22, 2016
@PureKrome
Copy link
Member

Hi @zahidmadeel - i just tried this with the latest code up on master and it worked for me :(

Also, I can't find that line of code, in my codebase ... ????

I understand what you wrote above .. but ... it's working for me. So I'm confused.

/me plays with the code somewhat...

this is a sample end point the code eventually hits/requests...

https://login.live.com/oauth20_token.srf/oauth20_token.srf?client_id=00000000400ED488&redirect_uri=http%3A%2F%2Fsimpleauthentication.localtest.me%3A1337%2Fauthentication%2Fauthenticatecallback%3Fproviderkey%3Dwindowslive&client_secret=some-secret-stuff&code=AA588c11d-6f3c-602a-a68d-307dfe33b63b&grant_type=authorization_code

So the current code .. it's working ...

Can you give me more details into what you are doing?

@PureKrome
Copy link
Member

@zahidmadeel

  • I've updated the code to do a POST when calling https://login.live.com/oauth20_token.srf/oauth20_token.srf
  • i've put up a pre-release package to MyGet (not nuget, but MyGet) which has this new code fix in.

MyGet feed details: https://www.myget.org/F/simpleauthentication/api/v2

here's a sample nuget.config file to drop into your root folder of your solution:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="SimpleAuthentication (MyGet)" value="https://www.myget.org/F/simpleauthentication/api/v2" />
   </packageSources>
</configuration>

I'm assuming you know how to grab a pre-release package AND the package is from another feed location ....

@zahidmadeel
Copy link
Author

@PureKrome

Basically that line of code is not in your codebase. Instead, I am using
your package with nancyfx and I wrote those lines of code. But they are
calling methods of your API. When I subclassed windowsLiveProvider and
changed request from GET to POST the problem disappeared.

On 22 June 2016 at 19:26, Pure Krome notifications@github.com wrote:

@zahidmadeel https://github.com/zahidmadeel

MyGet feed details: https://www.myget.org/F/simpleauthentication/api/v2

here's a sample nuget.config file to drop into your root folder of your
solution:

I'm assuming you know how to grab a pre-release package AND the package
is from another feed location ....


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#213 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABBKjJHo87KfWWOnroCVjWEBLlsOWJwsks5qOUYagaJpZM4I7r3N
.

Regards
Muhammad Adeel Zahid

@PureKrome
Copy link
Member

Sweet. So, can you try using my pre-release package I put up onto MyGet and test things out with your code, please?

@zahidmadeel
Copy link
Author

I will try using MyGet and update you as soon as possible

On 23 June 2016 at 06:35, Pure Krome notifications@github.com wrote:

Sweet. So, can you try using my pre-release package I put up onto MyGet
and test things out with your code, please?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#213 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABBKjB1YixfZYU-sm6yxrnbos3ZwIlz5ks5qOeLIgaJpZM4I7r3N
.

Regards
Muhammad Adeel Zahid

@PureKrome
Copy link
Member

@zahidmadeel yo :) any luck/new info?

@ARGibson
Copy link

Hi there,

I too had the same problem @zahidmadeel had and tried out the pre-release version you put up. This does resolve the Failed to obtain an Access Token issue however I now get Retrieved a Windows Live Access Token but it there's an error with either the access_token parameters. Access Token: -no access token-.

I configure the WindowsLive provider inside my nancy bootstrapper like so:

var liveProvider = new WindowsLiveProvider(new ProviderParams
{
    PublicApiKey = "<Client ID Here>",
    SecretApiKey = "<Password Here>",
    Scopes = new List<string> { "openid","email" }, 
});

I've not had a chance to dig into exactly what the Azure AD OAuth response was yet or why there was no token or even if it is a SimpleAuthenticator issue bit I figured some feedback may be of use to you.

Cheers,
Andy

@jcdickinson
Copy link

jcdickinson commented Oct 14, 2016

@PureKrome I tried out the pre-release (0.7.4-dev) and it seems to resolve the issue. Nancy Web.config-based.

Additionally, Live are accepting localhost redirect URIs now - you can remove the workaround from the readme.

@PureKrome
Copy link
Member

@jcdickinson do you know when MS-Live started accepting localhost redirect uri's?

@jcdickinson
Copy link

@PureKrome I have absolutely no idea, I gave it a shot today and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants