【发布时间】:2015-12-28 12:55:34
【问题描述】:
我正在尝试按照此处的 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
但是,当我尝试完成文档中的第二步“为访问令牌交换授权代码”(使用发布请求)时,我无法授权。使用这个命令:
curl --data "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": "2015 年 9 月 30 日星期三 16:21:26 +0000" , "message": "授权失败。", "data": null}
我也尝试在 Python 中使用 requests 库,但结果相同。我还注意到,在第一步中,您可以将“code”更改为“token”并获得包含“access_token=”的结果,但我不能交换它或直接使用它来访问。
非常感谢任何指导!
【问题讨论】:
标签: python api curl oauth pinterest