Error with token exchange requests in Google Smart home

回眸只為那壹抹淺笑 提交于 2020-02-16 08:23:49

问题


I´m following this Google documentation to make account linking with oauth. In the token exchange requests item, I am receiving the JSON below, as expected:

{
   "client_id" : "*****",
   "client_secret" : "*****",
   "code" : "myauthorization_code",
   "grant_type" : "authorization_code",
   "redirect_uri" : "https://oauth-redirect.googleusercontent.com/r/****"
}

and my response is:

{
    "access_token" : "myaccess_token",
    "expires_in" : 3600,
    "refresh_token" : "myrefresh_token",
    "token_type" : "Bearer"
}

But I am getting "Something went wrong, please try again later"`error, in Google assistant app in iOS. In stackdriver, I am getting the error:

SYNC: Request ID 4417600193631747637 failed with code: OPEN_AUTH_FAILURE

回答1:


Based on your example, it sounds like you are skipping a step. The account linking process has two steps:

  1. User authorization (user signs in to their account)
  2. Token exchange (server returns a token for the authorized user)

It looks like you responded to the authorization request directly by providing a token. The authorization request should return a unique temporary code representing the user who authorized, which will be passed back to your token exchange endpoint to get the access token.

You can read more about how to implement account linking with your OAuth server in the documentation.


Testing Account Linking

You can use the Google OAuth Playground to verify that your account linking implementation is working properly. Here is how you can configure this tool to test your endpoint:

  1. Open the Settings gear, change OAuth endpoints to Custom
  2. Enter your authorization and token URLs from the Actions console
  3. Enter your client ID and secret from the Actions console

You won't be authorizing any Google APIs, so for Step 1 you can just enter something like "devices" and click Authorize APIs. You can follow through with the flow in Step 2 to verify that the authorization and token exchange work properly. The tool will report if any errors occur in the flow.



来源:https://stackoverflow.com/questions/57221898/error-with-token-exchange-requests-in-google-smart-home

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!