Google 操作:帐户链接向令牌发送 GET 请求 URL

Google Actions: Account linking sends GET request to token URL

我对 Google 操作的帐户链接有一些问题:

我已经实施了 Google 文档中描述的 OAuth2 步骤。我已经实现了我的 OAuth2 服务器并通过 Postman 对其进行了测试,并且能够按预期获得访问令牌。

如果我尝试通过将服务添加到我的帐户来从 Google Home 应用程序进行身份验证,我将被带到我的授权表单,授权工作正常并使用授权代码响应 Google 的重定向 URI,因为它应该这样做。但是 Googles return URI 说 'Account linking failed' 然后我在 Google 家庭应用程序中收到一条消息:'无法更新设置。检查您的连接'。

我从令牌 URL 脚本的日志记录中看到的另一件奇怪的事情:我可以看到从 Google 到我的令牌 URL 的传入 GET 请求,而不是POST 请求包含 Google 文档中提到的所需数据。因此,即使消息 'Account linking failed' 出现,似乎 Google 正在调用我的令牌 URL,但使用 GET 而不是 POST。

这些是令牌请求的日志 URL:

REQUEST FROM POSTMAN(测试软件)> OK

__SERVER
Array
(
    [USER] => www-data
    [HOME] => /var/www
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_ACCEPT] => */*
    [HTTP_USER_AGENT] => PostmanRuntime/7.6.1
    [HTTP_POSTMAN_TOKEN] => f85664e2-7d38-4511-9519-cddda3feec06
    [HTTP_CACHE_CONTROL] => no-cache
    [HTTP_CONTENT_TYPE] => application/x-www-form-urlencoded
    [HTTP_CONTENT_LENGTH] => 145
    [HTTP_CONNECTION] => close
    [HTTP_HOST] => 127.0.0.1
    [REDIRECT_STATUS] => 200
    [SERVER_NAME] => _
    [SERVER_PORT] => 80
    [SERVER_ADDR] => 127.0.0.1
    [REMOTE_PORT] => 38622
    [REMOTE_ADDR] => 127.0.0.1
    [SERVER_SOFTWARE] => nginx/1.12.2
    [GATEWAY_INTERFACE] => CGI/1.1
    [REQUEST_SCHEME] => http
    [SERVER_PROTOCOL] => HTTP/1.0
    [DOCUMENT_ROOT] => [******]
    [DOCUMENT_URI] => /google/token/index.php
    [REQUEST_URI] => /google/token/
    [SCRIPT_NAME] => /google/token/index.php
    [CONTENT_LENGTH] => 145
    [CONTENT_TYPE] => application/x-www-form-urlencoded
    [REQUEST_METHOD] => POST
    [QUERY_STRING] =>
    [SCRIPT_FILENAME] => [******]
    [FCGI_ROLE] => RESPONDER
    [PHP_SELF] => /google/token/index.php
    [REQUEST_TIME_FLOAT] => 1553765980.9273
    [REQUEST_TIME] => 1553765980
)
__POST
Array
(
    [client_id] => [******]
    [client_secret] => [******]
    [grant_type] => authorization_code
    [code] => [******]
)

在智能手机上使用 GOOGLE HOME 应用进行测试时收到请求 > 不正常

__SERVER
Array
(
    [USER] => www-data
    [HOME] => /var/www
    [HTTP_ACCEPT_ENCODING] => gzip,deflate,br
    [HTTP_USER_AGENT] => OpenAuth
    [HTTP_CONTENT_TYPE] => application/x-www-form-urlencoded
    [HTTP_CONNECTION] => close
    [HTTP_HOST] => 127.0.0.1
    [REDIRECT_STATUS] => 200
    [SERVER_NAME] => _
    [SERVER_PORT] => 80
    [SERVER_ADDR] => 127.0.0.1
    [REMOTE_PORT] => 46184
    [REMOTE_ADDR] => 127.0.0.1
    [SERVER_SOFTWARE] => nginx/1.12.2
    [GATEWAY_INTERFACE] => CGI/1.1
    [REQUEST_SCHEME] => http
    [SERVER_PROTOCOL] => HTTP/1.0
    [DOCUMENT_ROOT] => [******]
    [DOCUMENT_URI] => /google/token/index.php
    [REQUEST_URI] => /google/token/
    [SCRIPT_NAME] => /google/token/index.php
    [CONTENT_LENGTH] =>
    [CONTENT_TYPE] => application/x-www-form-urlencoded
    [REQUEST_METHOD] => GET
    [QUERY_STRING] =>
    [SCRIPT_FILENAME] => [******]
    [FCGI_ROLE] => RESPONDER
    [PHP_SELF] => /google/token/index.php
    [REQUEST_TIME_FLOAT] => 1553767309.7797
    [REQUEST_TIME] => 1553767309
)
__REQUEST
Array
(
)
__POST
Array
(
)
__GET
Array
(
)
-------------------------
__ANSWER
400: invalid grant

Configuration in Actions Console

问题似乎是由 / 重定向到没有 POST 值的 /index.php 引起的。

通过将我在 Actions Console 中的 URL 更改为 /index.php 来修复它,现在链接工作正常。