获取访问令牌
Get an access token
我试图通过 google 文档获取访问令牌。
curl -L -X POST 'https://www.googleapis.com/oauth2/v4/token?
client_id=oauth2-client-id& client_secret=oauth2-client-secret&
code=authorization-code& grant_type=authorization_code&
redirect_uri=https://www.google.com'
这个请求没有成功。
我添加了 -H 'Content-Length: 0'
,现在我以
结尾
{
"error": "invalid_grant",
"error_description": "Bad Request"
}
有人有想法吗?
您的请求中似乎有一个 space:
/v4/token? client_id=oauth2-client-id
当我试图从文档中复制过去的命令时,它不起作用。
我必须 re-edit 请求才能使用它并且它起作用了。
我遇到了同样的问题。
curl -L -X POST "https://www.googleapis.com/oauth2/v4/token?client_id=<client_id>.apps.googleusercontent.com&client_secret=<secret>&code=4/4wGANiKF5......N0Jg&grant_type=authorization_code&redirect_uri=https://www.google.com"
难倒
你不需要使用不同的 redirect_uri 吗?您自己配置的重定向 uri?
如果修复 space 无效,re-do 您在此处链接 from the Google guide,步骤 1-6。然后得到一个新的授权码。我遇到了同样的问题,re-linking 为我工作(使用 -H 标志)。
我试图通过 google 文档获取访问令牌。
curl -L -X POST 'https://www.googleapis.com/oauth2/v4/token? client_id=oauth2-client-id& client_secret=oauth2-client-secret& code=authorization-code& grant_type=authorization_code& redirect_uri=https://www.google.com'
这个请求没有成功。
我添加了 -H 'Content-Length: 0'
,现在我以
{
"error": "invalid_grant",
"error_description": "Bad Request"
}
有人有想法吗?
您的请求中似乎有一个 space:
/v4/token? client_id=oauth2-client-id
当我试图从文档中复制过去的命令时,它不起作用。
我必须 re-edit 请求才能使用它并且它起作用了。
我遇到了同样的问题。
curl -L -X POST "https://www.googleapis.com/oauth2/v4/token?client_id=<client_id>.apps.googleusercontent.com&client_secret=<secret>&code=4/4wGANiKF5......N0Jg&grant_type=authorization_code&redirect_uri=https://www.google.com"
难倒
你不需要使用不同的 redirect_uri 吗?您自己配置的重定向 uri?
如果修复 space 无效,re-do 您在此处链接 from the Google guide,步骤 1-6。然后得到一个新的授权码。我遇到了同样的问题,re-linking 为我工作(使用 -H 标志)。