php-connect-rest-sample icon indicating copy to clipboard operation
php-connect-rest-sample copied to clipboard

Hung Up on oAuth.php

Open mckrti opened this issue 9 years ago • 3 comments

I'm not sure if this is the same issue as the other one I created, but I tried moving the files onto the webserver, since working locally was giving me directory issues.

It goes through sign in at microsoft's website fine, but when it heads back to oauth.php, it gets stuck. I simply get a white page and the url is:

[url excluded]/oauth.php?code=OAQABAAIAAABnfiG-mA6NTae7CdWW7QfdVfRourtTf2VjH18UHuhTKX10t5VaJ3g1EE2rmr7AAObOAWWxiDng1TtjSmSNKx4zSiSvwlG911lwNz9EJuWcHSzNBktq1JCfR6vIKFQPE9lWp9FqUblRGNL41EMtcPiZf1Op_XTpb9j5JHYlXiwE1k8SUhqYr8bBLuNTU_bBDcCWGI8kmEk2yH7Lp0xovD_9-pp7todzCqVXpHeYXbghOLhowSJgJSyjw2Ji6InB4VRNRngWbSGkcEdT-MftO1y-7kPGfhFSbHffvsZNXKMD_1iNqIgSo5EyoA-rCw8e72t0CsnQwmF-aA0s_vINqt8yxGFU-NwxpuUa3NEyxfVHasrvt5EmLX0d1FWSDzfaTCoA4jVcHKci5Yq3lgd_up6Bv5s-OdgPSqF5fgRmoNPrKtAy_og6XM-slgMW1c-3G6l96ZePjYIJ7X_pZVaOpcH64PIAhwgFNArUPCDQgrvQM_2XkRN2my76UzrreRTPUK-VBd492ATVVIV-O1Jhjx8cbIJt5GdeM-9x4L-2tu876soqP9f6AucJC-HgW7zxlF-1_0KZcPssV5cZD_ks1VIbYaTqfFbaFukPJzGTQ2qHfJVvub8DN94nYVloiBd0FUjsX1ZG6dLKyydc9OONtPuk6ts8dmztI33H-yfw4JLqSmSJMEsji0dwNJp1bIMej7AGP6zmulyg8xhnMj_ybSZb-UJqfv_1ghhYPOuJ2mMG1xAa7x0GH5sLiRcR7OJOf5YgAA&state=83q4SjNsuXA134yleKoGPqWitxflC51T&session_state=9d56121d-40ab-4d62-9e8b-f570391dcd01

mckrti avatar Jun 06 '17 12:06 mckrti

Thanks for calling this to our attention. Thanks for calling this to our attention. We'll see if we can reproduce either issue. Have you tried this sample?

https://github.com/microsoftgraph/php-connect-sample

That one uses our Microsoft Graph PHP SDK.

jamescro avatar Jun 06 '17 16:06 jamescro

The code you're receiving in the URL completes step 1 of the authorization process. That should slot you into this else statement:

elseif ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['code'])) {

I would start debugging through this block to see whether the session is accessible and you are able to get a valid access token. You can also open Fiddler or Postman and try manually POSTing to the token endpoint to see if the service returns a valid access token. Sometimes you can retrieve a code from part 1 that does not produce a valid access token and requires you to fix your auth configuration.

You would make the POST request to:

https://login.microsoftonline.com/common/oauth2/v2.0/token

grant_type=authorization_code&code=$yourCode&scope=$yourScope&redirectUri=http://localhost:8000/oauth.php&client_id=$yourClientId&client_secret=$yourClientSecret

caitlinrussell avatar Jun 08 '17 00:06 caitlinrussell

Closing for now. Please reopen if this continues to be an issue.

jamescro avatar Nov 06 '17 16:11 jamescro