Google agent authorization flow doesn't proceed after the grantType=authorization_code request

末鹿安然 提交于 2019-12-12 10:43:33

问题


I am developing a API AI agent, and trying to implement the account linking functionality. The documentation at oauth2-codeflow is really helpful and I am able to create my oauth flow and test the same in Google playground. It all works fine till here.

But when I am trying to test it in the web simulator, I keep getting the "It looks like your Agent account is not linked yet". I've followed the debug URL and proceeded with the login and authorization steps.

As per this SO Question: I should be expecting the browser to be redirected to https://www.google.com/?result_code=SUCCESS&result_message=Accounts+now+linked, but my browser always gets redirected to https://www.google.co.in/?gws_rd=cr&ei=QDOEWfCAPMHA0gSUvJj4Ag and in the agent I still get accounts not linked message.

I can see that Google is able to invoke my tokens endpoint with grantType:authorization_code and my service responds as outlined below:

POST for /myendpoint/tokens has begun for: grantType:authorization_code  clientId:google-clientid...8

My service response is:

{
  "token_type":"bearer",
  "access_token":"ab092868.....e804bcac",
  "refresh_token":"e11e6d3054883...b30",
  "expires_in":3600
}

I've gone through the suggestion in the SO Question but my response has no additional parameters. It is plain and simple

I am sending the above response through a nodejs application with following code:

    res.setHeader('Cache-Control', 'no-store');
    res.setHeader('Pragma', 'no-cache');
    res.setHeader('Content-Type', 'application/json;charset=UTF-8');
    res.send(JSON.stringify(respObj)); 

I am really struck now, and couldn't find a way out! Kindly help.


回答1:


As noted via e-mail, it appears that you are not redirecting to the same URL as the redirect_uri parameter that is provided to your Authorization Endpoint during the sign-in flow. I am going to investigate improving the messaging around this error.




回答2:


I got redirected to the same gws_rd=cr&ei url and it was because we were developing NOT in the USA. Tried to VPN to Seattle and it then worked and redirected to the google.com homepage with result_code=SUCCESS. I think Google is region blocking somewhere in the process.



来源:https://stackoverflow.com/questions/45502199/google-agent-authorization-flow-doesnt-proceed-after-the-granttype-authorizatio

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