简体   繁体   中英

Unable to complete Google Home Account Linking Process. (Invalid State Parameter. The Link can not be completed.)

I am new to Google Actions. I am building action to access my smart home device from google home/assistance. I have already filled the Account Linking details from my auth server on action console.

在此处输入图像描述

I have provided the Fulfillment URL on Actions tab.

在此处输入图像描述

When I try to link the account from Google App (ie Home > + > Set up device > Works with Google > [test] My_Action, it redirect to my server's Authorization, there I submit my server's username and password and it redirect back to google home page and my account is successfully linked and my devices are showing in the Google Home.

But, When I try to link my account using OAuth 2.0 ( https://developers.home.google.com/cloud-to-cloud/project/authorization ) it doesn't link the account.

Here are the steps I follow.

  1. Open the URL in the browser.
https://auth-dev.iotondemand.com/oauth/authorize?client_id=client&redirect_uri=https://oauth-redirect-sandbox.googleusercontent.com/r/MY_PROJECT_ID&state=somerandomstring&scope=read+write&response_type=code&user_locale=en

It opens the login screen of my server, when I submit my credentials it redirect to the following url along with authorization code which is generated by my auth server and the state parameter.

https://oauth-redirect-sandbox.googleusercontent.com/r/MY_PROJECT_ID?code=VGdKtk&state=somerandomstring

And

'Invalid State Parameter. The Link can not be completed.'

this is written on browser.

Invalid State Parameter. The Link can not be completed.

在此处输入图像描述

What's wrong am I doing? I am passing some random string to my authorization url and it gives back the same string and redirect it to oauth-redirect-sandbox.googleusercontent.

My action is still in development mode. I haven't deployed it yet.

If you are able to complete account linking using the Google Home App, you are good to go with your implementation. This flow is also using OAuth2.0, where the user is sent to your authorization url to fill in credentials, then Google servers will use the authorization code you provided in this flow to retrieve access and refresh tokens from your token url. (The fulfillment url you provided is not used throughout the Account Linking process)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM