stevenmaguire / oauth2-microsoft

Microsoft OAuth 2.0 support for the PHP League's OAuth 2.0 Client
MIT License
68 stars 41 forks source link

Trying to use to connect to O365 dev trial acct - get Bad Request #9

Closed brian2github closed 6 years ago

brian2github commented 7 years ago

Not sure if an issue or I just need help in troubleshooting...

[24-Aug-2017 05:15:56 UTC] PHP Fatal error: Uncaught exception 'League\OAuth2\Client\Provider\Exception\IdentityProviderException' with message 'Bad Request' in /home/(user)/vendor/stevenmaguire/oauth2-microsoft/src/Provider/Microsoft.php:79 Stack trace:

0 /home/(user)/vendor/league/oauth2-client/src/Provider/AbstractProvider.php(613): Stevenmaguire\OAuth2\Client\Provider\Microsoft->checkResponse(Object(GuzzleHttp\Psr7\Response), Array)

1 /home/(user)/vendor/league/oauth2-client/src/Provider/AbstractProvider.php(528): League\OAuth2\Client\Provider\AbstractProvider->getParsedResponse(Object(GuzzleHttp\Psr7\Request))

2 /home/(user)/public_html/oauth-test/test.php(62): League\OAuth2\Client\Provider\AbstractProvider->getAccessToken('authorization_c...', Array)

3 {main}

thrown in /home/(user)/vendor/stevenmaguire/oauth2-microsoft/src/Provider/Microsoft.php on line 79

What is happening is that I launch my PHP, it redirects to MS for login. I login, and it redirects me back to my page with additional query string info. At that point I get the error above.

stevenmaguire commented 7 years ago

Please share more of the code that is interacting with the package.

brian2github commented 7 years ago

test_php_code

oabreu commented 7 years ago

@brian2github @stevenmaguire Same problem for me, code like that one, any solution? thanks

jcrumpOS commented 6 years ago

I'm trying to Connect to Microsoft Dynamics 365 web services using OAuth, have tried this code and can't get it to work yet, has anyone been successful in connecting and using the Web API?

oabreu commented 6 years ago

@jcrumpOS On this list https://github.com/thephpleague/oauth2-client/blob/master/docs/providers/thirdparty.md this one is not working for me,and for what i have read,for no one. Use Azure Active Directory Oauth from this list https://github.com/thenetworg/oauth2-azure , that one worked for me like a charm :) , hope this will help u

stevenmaguire commented 6 years ago

@oabreu is on the right track. Microsoft is a large organization and they offer several APIs and Authorization flows. Consider trying the other Microsoft specific oauth2 libraries.

jcrumpOS commented 6 years ago

Thanks, I've tried that and get the same message:

Fatal error: Uncaught exception 'League\OAuth2\Client\Provider\Exception\IdentityProviderException' with message 'Unauthorized'

stevenmaguire commented 6 years ago

@jcrumpOS have you attempted your auth flow using the azure specific oauth2 library?

https://github.com/thenetworg/oauth2-azure

jcrumpOS commented 6 years ago

Thanks, yes it's working now.