0

按照以下网站上的说明进行操作时,我陷入了第 2 步。

https://developers.google.com/assistant/smarthome/tools/smart-home-test-suite

单击“交换令牌的授权码”后,我没有收到任何代码,而是出现401 Unauthorized错误。

不知道在此测试期间出了什么问题,因为该操作本身运行良好。

这是 OAuth 游乐场的输出:

Host: oauth.teletask.be 
Content-length: 169 
content-type: application/x-www-form-urlencoded 
user-agent: google-oauth-playground

code=XIspHj&redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&client_id=***********&client_secret=************&scope=&grant_type=authorization_code

HTTP/1.1 401 Unauthorized 
X-xss-protection: 1; mode=block 
X-content-type-options: nosniff 
Transfer-encoding: chunked 
Expires: 0 
Www-authenticate: Basic realm="oauth2/client" 
Server: nginx/1.14.1 
Connection: keep-alive 
Pragma: no-cache 
Cache-control: no-cache, no-store, max-age=0, must-revalidate 
Date: Thu, 21 Nov 2019 14:59:59 GMT 
Strict-transport-security: max-age=31536000 ; includeSubDomains 
Content-type: application/json;charset=UTF-8 
X-frame-options: DENY

{
    "status": 401,
    "timestamp": "2019-11-21T14:59:59.599+0000",
    "message": "Unauthorized",
    "path": "/auth/oauth/token",
    "error": "Unauthorized" 
}
4

1 回答 1

0

该 401 错误是由您的 OAuth 服务器 ( oauth.teletask.be) 生成的,特别是您作为Token 端点输入的端点,当它收到来自 Google 的授权代码授权时。您应该检查您的服务器日志,以确定有关它拒绝请求的原因的更多详细信息。

这里的常见问题包括拒绝redirect_uriorclient_id因为它们与预期值不匹配。也可能是您的授权代码的生命周期太短,并且代码在您按下按钮以将其交换为令牌之前就过期了。

于 2019-12-10T05:52:46.033 回答