Oauth2 Playground exchange authorization code for token: 400 error -


i've been following basic oauth 2.0 tutorial create oauth 2.0 server. whole part worked fine, when tried play around in google oauth2 playground following this page i'm getting errors.

i've followed steps in above link except used http://localhost/wordpress/authorize.php?state=xyz authorization endpoint because otherwise error saying state required , didn't want edit code yet.

now, seems work fine authorizing apis. i'm directed localhost site , when authorize request returned oauth2 playground. when go on next step , attempt exchange returned authorization code token, given 400 error.

the whole request/response follows:

post /wordpress/token.php http/1.1 host: localhost content-length: 191 content-type: application/x-www-form-urlencoded user-agent: google-oauth-playground  code=6d408c28d468db6586320bff3aacf16492489b67&redirect_uri=https%3a%2f%2fdevelopers.google.com%2foauthplayground&client_id=newclient&scope=& client_secret=newpass&grant_type=authorization_code ______________________________________________________________________  http/1.1 400 bad request content-length: 106 content-type: text/plain  error occured while connecting server: unable fetch url: http://localhost/wordpress/token.php 

this may simple error i've made on end can't seem figure out. don't think code problem because when tests on tutorial page works fine. have not edited of files library example uses. if needed, can edit post include code comply rule links may become inactive.

one thing noticed request little bit &scope=&client_secret=newpass&grant_type=authorization_code. looks there no scope parameter set , thinking might messing results.

if has experience oauth or oauth2 playground , me figure out things went wrong grateful. also, apologize long question wanted include info could.

this happening because hosting oauth server on non accessible network (e.g. localhost). when oauth playground tries exchange code token using own server (not using xhr on webpage) , server not have access machine using url http://localhost....

to test playground need make oauth 2.0 server reachable public url or ip address.what can instead expose local service outside/internet. can use services such ngrok or localtunnel , you'll public url local service you'll able setup playground with.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -