【发布时间】:2019-05-05 14:07:44
【问题描述】:
我需要在 Postman 中创建从 Google Analytics API 获取数据的请求。我设法使用游乐场平台生成访问令牌,但我需要永久刷新令牌(在游乐场我只能生成 24 小时令牌)。
我尝试在控制台 API 中生成令牌:
- 我已经创建了项目
- 在我的项目中添加分析 API
- 生成客户端 ID 和密码
但我不知道使用哪个重定向 URL。在 JSON 中生成的默认值为 urn:ietf:wg:oauth:2.0:oob","http://localhost
比我生成的带有请求的授权码(来自浏览器):
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/analytics&redirect_uri=http://localhost&response_type=code&client_id=XXXX
当我尝试在 Postman 中使用 POST 请求生成 access_token 时,发送这样的密钥:
code:XXXXXX
redirect_uri:urn:ietf:wg:oauth:2.0:oob (also tryed http://localhost)
client_id:YYYYY
client_secret:ZZZZZZ
scope:https://www.googleapis.com/auth/analytics
grant_type:authorization_code
出现错误
{
"error": "invalid_grant",
"error_description": "Bad Request"
}
我应该如何为 Postman 设置授权?你能帮我解决问题并理解我做错了什么吗
【问题讨论】:
-
我尝试在 Oath2 页面的 Postman 中生成令牌 - 但出现错误“无法完成 oauth2.0 登录”
标签: google-api postman google-analytics-api