python - Unable to authorise with Pinterest API Oauth -


i trying follow pinterest api instructions here: https://developers.pinterest.com/docs/api/authentication/.

i can complete first step, obtaining access code, url: https://api.pinterest.com/oauth/?response_type=code&redirect_uri=https://localhost/&client_id=xxxxxxxxxxxxx&client_secret=yyyyyyyyyyyyyyyyy&scope=read_public,write_public&state=myystatestring

that gives me code: https://localhost/?code=zzzzzzzzzzzz&state=mystatestring

however, when try , complete second step docs, 'exchanging authorization code access token' (using post request), can't authorise. using command:

curl --data "grant_type=authorization_code&client_id=xxxxxxxxxxxxxxx&code=zzzzzzzzzzz" https://api.pinterest.com/v1/oauth/token

i get:

{"status": "failure", "code": 3, "host": "coreapp-devplatform-devapi-171", "generated_at": "wed, 30 sep 2015 16:21:26 +0000", "message": "authorization failed.", "data": null}

i've tried using requests library within python also, same result. i've noticed in first step can change 'code' 'token' , result includes 'access_token=', can't either exchange or use access directly.

any guidance appreciated!

and see has been asked , answered yesterday, @ question: auth exception in pinterest api

"the docs wrong. have include client_secret in step (step 2), not step 1. add "&client_secret=" poststr. – zack argyle"

once changed worked perfectly:

curl --data "grant_type=authorization_code&client_id=xxxxxxxxxxxxxxx&code=zzzzzzzzzzz&client_secret=yyyyyyyyyyyyyyyyy" https://api.pinterest.com/v1/oauth/token

response:

{"access_token": "token_string_here", "token_type": "bearer", "scope": ["read_public", "write_public", "read_private", "write_private", "read_write_all"]}

thanks zack!


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -