"Accounts failed to link" 当我尝试在我的 Web 服务上授权 Google 助手时发生错误
"Accounts failed to link" error happens when I try to authorize Google Assistant at my Web service
首先,我想提一下,以前在以下主题中讨论过这样的问题:
但我找不到任何与使用我自己的网络服务器 linking Google 助手应用程序相关的信息。
问题:
获取https://oauth-redirect.googleusercontent.com/r/my-google-assistant-app#access_token=ACCESS_TOKEN&token_type=bearer&state=STATE always returns "Account field to link" error
重现方式:
- 我在 Google 控制台上的操作中创建了一个新项目
- 我使用 Dialogflow 构建了一个应用程序
- 我创建了一个 Heroku Web 服务器作为我的 webhook(例如:webhook.herokuapp.com)
所以一切正常。我已成功将我的 Google 智能助理应用程序与我的网络钩子连接起来。
但后来我决定将请求发送到我的另一个需要用户登录的 Heroku Web 服务器(例如:webserver.herokuapp.com)。所以我决定使用 webserver.herokuapp.com
实现我的 Google 助手应用程序的帐户 linking
- 我在 webserver.herokuapp.com 实现了 Google-OAuth2 授权。另外我想提一下,我使用了 Google Assistant App
的 Client ID 和 Client Secret
因此,Google 授权在我的 网络服务器 上完美运行。herokuapp.com
- 然后我使用隐式流
为我的 Google 助手应用程序启用帐户 linking 设置
所以,就是这样!
结语
我打开 Google 助手,告诉它 "Talk to my test app",然后它向我打招呼并向我提供 link 帐户。我说 "yes"。
然后我看到 Google 助理如何在 webserver.herokuapp.com 请求我的登录 URL。然后我输入我的 Google 电子邮件和密码。结果我登录了我的网络服务器!然后我的网络服务器重定向到:
我得到了我在 post.
顶部描述的错误
如有任何帮助,我们将不胜感激
UPDATE 带参数信息
These are my constants:
Google Assistant Project_ID = nodejs-sdk-local-test
Google Assistant Client_ID = 1067979601708-ldr3ga115es3fdo823slfnj46gjoes66.apps.googleusercontent.com
state = manually_set_state_value
流程是我打开 Google 助手并说 "Ok Google, talk to my test app",它回答了我的请求,然后我说了类似 "do some action which need authorization" 的内容。 Google 助理应用向我提供了 link 一个帐户,我说 "Yes"。
这是 Google 助手应用程序调用我的 https://webserver.herokuapp.com/google-oauth2
端点的地方。此端点的目的是将我重定向到 Google 登录页面。
现在我被重定向到 Google 登录页面(一切似乎都是正确的。client_id
和 state
参数类似于常量) .这是我被重定向到的 URL 的示例:https://accounts.google.com/o/oauth2/auth?client_id=1067979601708-ldr3ga115es3fdo823slfnj46gjoes66.apps.googleusercontent.com&redirect_uri=http://webserver.herokuapp.com/complete/google-oauth2/&state=manually_set_state_value&response_type=code&scope=openid+email+profile
在 Google 登录页面,我输入我的凭据,然后我被重定向到 redirect_uri=http://webserver.herokuapp.com/complete/google-oauth2
端点。此端点的目的是在 webserver.herokuapp.com
注册或登录我,然后将我重定向到另一个 Google URL。 GoogleURL的例子:https://oauth-redirect.googleusercontent.com/r/nodejs-sdk-local-test#access_token=<token_omitted>&token_type=bearer&state=manually_set_state_value
看来一切都是对的。我登录到 webserver.herokuapp.com
,获得了一个访问令牌。最后一个GoogleURL中的project_id
和state
参数也类似于常量。反正这个GoogleURLreturns我一个错误"Accounts failed to link"!
最常见的原因是您没有传回在 Google 重定向到您的站点时发送给您的 state
的相同值。请确保这是相同的值,并且为了您的安全,请确保您也验证了发送给您的其他参数。
当用户被重定向到 https://webserver.herokuapp.com/google-oauth2
时,应该有一些参数作为查询的一部分发送。这些参数包括一个 state
参数。它应该看起来像这样:
https://myservice.example.com/auth?client_id=GOOGLE_CLIENT_ID&redirect_uri=REDIRECT_URI&state=STATE_STRING&response_type=token
请注意,虽然 client_id
和 redirect_uri
是您应该预期和测试的值,但 state
值 而不是 你会设置。 Google 每次生成一个不同的。这是您稍后重定向到
时应该使用的 state
https://oauth-redirect.googleusercontent.com/r/nodejs-sdk-local-test#access_token=<token_omitted>&token_type=bearer&state=STATE_STRING
首先,我想提一下,以前在以下主题中讨论过这样的问题:
但我找不到任何与使用我自己的网络服务器 linking Google 助手应用程序相关的信息。
问题:
获取https://oauth-redirect.googleusercontent.com/r/my-google-assistant-app#access_token=ACCESS_TOKEN&token_type=bearer&state=STATE always returns "Account field to link" error
重现方式:
- 我在 Google 控制台上的操作中创建了一个新项目
- 我使用 Dialogflow 构建了一个应用程序
- 我创建了一个 Heroku Web 服务器作为我的 webhook(例如:webhook.herokuapp.com)
所以一切正常。我已成功将我的 Google 智能助理应用程序与我的网络钩子连接起来。
但后来我决定将请求发送到我的另一个需要用户登录的 Heroku Web 服务器(例如:webserver.herokuapp.com)。所以我决定使用 webserver.herokuapp.com
实现我的 Google 助手应用程序的帐户 linking- 我在 webserver.herokuapp.com 实现了 Google-OAuth2 授权。另外我想提一下,我使用了 Google Assistant App 的 Client ID 和 Client Secret
因此,Google 授权在我的 网络服务器 上完美运行。herokuapp.com
- 然后我使用隐式流
所以,就是这样!
结语
我打开 Google 助手,告诉它 "Talk to my test app",然后它向我打招呼并向我提供 link 帐户。我说 "yes"。 然后我看到 Google 助理如何在 webserver.herokuapp.com 请求我的登录 URL。然后我输入我的 Google 电子邮件和密码。结果我登录了我的网络服务器!然后我的网络服务器重定向到:
我得到了我在 post.
顶部描述的错误如有任何帮助,我们将不胜感激
UPDATE 带参数信息
These are my constants:
Google Assistant Project_ID = nodejs-sdk-local-test
Google Assistant Client_ID = 1067979601708-ldr3ga115es3fdo823slfnj46gjoes66.apps.googleusercontent.com
state = manually_set_state_value
流程是我打开 Google 助手并说 "Ok Google, talk to my test app",它回答了我的请求,然后我说了类似 "do some action which need authorization" 的内容。 Google 助理应用向我提供了 link 一个帐户,我说 "Yes"。
这是 Google 助手应用程序调用我的
https://webserver.herokuapp.com/google-oauth2
端点的地方。此端点的目的是将我重定向到 Google 登录页面。现在我被重定向到 Google 登录页面(一切似乎都是正确的。
client_id
和state
参数类似于常量) .这是我被重定向到的 URL 的示例:https://accounts.google.com/o/oauth2/auth?client_id=1067979601708-ldr3ga115es3fdo823slfnj46gjoes66.apps.googleusercontent.com&redirect_uri=http://webserver.herokuapp.com/complete/google-oauth2/&state=manually_set_state_value&response_type=code&scope=openid+email+profile
在 Google 登录页面,我输入我的凭据,然后我被重定向到
redirect_uri=http://webserver.herokuapp.com/complete/google-oauth2
端点。此端点的目的是在webserver.herokuapp.com
注册或登录我,然后将我重定向到另一个 Google URL。 GoogleURL的例子:https://oauth-redirect.googleusercontent.com/r/nodejs-sdk-local-test#access_token=<token_omitted>&token_type=bearer&state=manually_set_state_value
看来一切都是对的。我登录到
webserver.herokuapp.com
,获得了一个访问令牌。最后一个GoogleURL中的project_id
和state
参数也类似于常量。反正这个GoogleURLreturns我一个错误"Accounts failed to link"!
最常见的原因是您没有传回在 Google 重定向到您的站点时发送给您的 state
的相同值。请确保这是相同的值,并且为了您的安全,请确保您也验证了发送给您的其他参数。
当用户被重定向到 https://webserver.herokuapp.com/google-oauth2
时,应该有一些参数作为查询的一部分发送。这些参数包括一个 state
参数。它应该看起来像这样:
https://myservice.example.com/auth?client_id=GOOGLE_CLIENT_ID&redirect_uri=REDIRECT_URI&state=STATE_STRING&response_type=token
请注意,虽然 client_id
和 redirect_uri
是您应该预期和测试的值,但 state
值 而不是 你会设置。 Google 每次生成一个不同的。这是您稍后重定向到
state
https://oauth-redirect.googleusercontent.com/r/nodejs-sdk-local-test#access_token=<token_omitted>&token_type=bearer&state=STATE_STRING