Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 513
Phani Avatar asked Aug 04 '17 08:08

Phani


1 Answers

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.

like image 171
foxxtrot Avatar answered Jan 02 '23 21:01

foxxtrot