Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google OAuth 2: response_type error on token request

I am trying to return an OAuth 2 response code for an OAuth response token. However, my request returns the following error which has zero results in google. I tried changing response_type to "token" instead of "code" but that didn't work either.

OAuth 2 parameters can only have a single value: response_type

Request Details:

scope=https://www.googleapis.com/auth/userinfo.email
client_secret=_____
response_type=code
grant_type=authorization_code
redirect_uri=http://localhost/folder/
client_id=____.apps.googleusercontent.com
code=_____

I'm sending this second-step payload to POST https://accounts.google.com/o/oauth2/auth

What is wrong with my request?

Edit

I just realized that there is the https://accounts.google.com/o/oauth2/token URL that should be used for this request. However, changing to that URL now gives:

HTTP/1.0 400 Bad Request
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Date: Fri, 27 Jul 2012 22:44:35 GMT
Content-Type: application/json
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE

{
  "error" : "invalid_request"
}

Edit 2

Removing the response_type and changing the URL like above solved this.

like image 751
Xeoncross Avatar asked Jul 27 '12 22:07

Xeoncross


1 Answers

After receiving the authorization code you have to ask '/o/oauth2/token' for the access token. This request takes no 'scope' and no 'response_type' parameters. See the Google documentation for more details.

like image 110
Jan Gerlinger Avatar answered Oct 20 '22 19:10

Jan Gerlinger