我想在这里遵循Pinterest API说明:https://developers.pinterest.com/docs/api/authentication/ .
我可以使用以下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
这给了我代码:https://localhost/?code=ZZZZZZZZZZZZ&state=mystatestring
但是,当我尝试完成文档中的第二步“交换访问令牌的授权代码”(使用发布请求)时,我无法授权 . 使用此命令:
卷曲 - 数据"grant_type=authorization_code&client_id=XXXXXXXXXXXXXXX&code=ZZZZZZZZZZZ" https://api.pinterest.com/v1/oauth/token
我明白了:
{“status”:“failure”,“code”:3,“host”:“coreapp-devplatform-devapi-171”,“generated_at”:“Wed,30 Sep 2015 16:21:26 0000”,“message” :“授权失败 . ”,“数据”:null}
我也试过在Python中使用请求库,但结果相同 . 我还注意到,在第一步中,您可以将“代码”更改为“令牌”并获得包含“access_token =”的结果,但我无法将其交换或直接用于访问 .
任何指导非常感谢!
2 回答
实际上,我现在看到昨天在这个问题上已经被问到并回答:Auth Exception in Pinterest API
“文档是错误的 . 你必须在这一步(步骤2)中包含你的client_secret,而不是步骤1.所以将”&client_secret =“添加到postStr . - Zack Argyle”
一旦我改变它,它完美地工作:
卷曲 - 数据"grant_type=authorization_code&client_id=XXXXXXXXXXXXXXX&code=ZZZZZZZZZZZ&client_secret=YYYYYYYYYYYYYYYYY" https://api.pinterest.com/v1/oauth/token
响应:
{“access_token”:“token_string_here”,“token_type”:“bearer”,“scope”:[“read_public”,“write_public”,“read_private”,“write_private”,“read_write_all”]}
谢谢扎克!
我知道很多时间过去但第二个URL必须像https://api.pinterest.com/v1/oauth/token?grant_type=authorization_code&client_id=XXXXXXXXXXX&client_secret=XXXXXXXXXXXXX&code=XXXXXXXXXXXX
在原始帖子中,app秘密丢失了