【发布时间】:2019-07-03 16:24:03
【问题描述】:
根据their documentation/guide 向 Google OAuth2 API 发出请求时,我不断收到来自https://accounts.google.com/oauth2/v4/token 的401 Unauthorized 响应,即使我发誓我提供了所有必填字段:
POST /oauth2/v4/token HTTP/1.1
Host: www.googleapis.com
User-Agent: curl/7.47.0
Accept: */*
Content-Length: 311
Content-Type: application/x-www-form-urlencoded
client_id=REDACTED
&client_secret=REDACTED
&code=REDACTED
&grant_type=authorization_code
&redirect_uri=https%3A%2F%2Flocalhost%2Fsso%3Fredirect%3D%252F
回复:
HTTP/1.1 401 Unauthorized
Content-Type: application/json; charset=utf-8
Vary: X-Origin
Vary: Referer
Date: Wed, 03 Jul 2019 16:14:15 GMT
Server: scaffolding on HTTPServer2
Cache-Control: private
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Alt-Svc: quic=":443"; ma=2592000; v="46,43,39"
Accept-Ranges: none
Vary: Origin,Accept-Encoding
Transfer-Encoding: chunked
{
"error": "invalid_client",
"error_description": "Unauthorized"
}
我已经检查并三重检查了我的 client_id、client_secret、授权主机和 redirect_uri,并查看了堆栈溢出的类似问题,但似乎没有任何工作......为什么这会发生在我身上:(
【问题讨论】:
标签: http oauth-2.0 google-oauth