javarestactions-on-googleoltu

Authorization grant flow failed when linking account with Google Home device


I'm able to redirect authorization code back to redirect url which can be seen in oauth2.0 playground tool.But i am getting null values in parameters like client_id,client_secret,grant_type and code when accessing token from authorization server.Here is the redirect url sending authorization code

https://oauth-redirect.googleusercontent.com/r/skillid?state=xyz&code=aW1vbml

Http/1.1 400 Bad Request Content-type: application/json; charset=UTF-8 { "error_description": "Bad Request", "error": "invalid_grant"}

OAuthASResponse.OAuthAuthorizationResponseBuilder builder = OAuthASResponse .authorizationResponse(request,HttpServletResponse.SC_FOUND);' builder.setParam("code", token); builder.setParam("state", state); final OAuthResponse response = builder.location(redirectURI).buildQueryMessage(); URI url = new URI(response.getLocationUri()); return Response.status(response.getResponseStatus()).location(url).build();


Solution

  • I finally found out that i have to use @Formparameters to pick post request for authrization grant flow to exchange token with authorization code.