I get the same behavior. I'm creating the request in JavaScript using
the xmlhttprequest object.
Using FireBug in Firefox I get the console error
"POST
https://accounts.google.com/o/oauth2/token 400 Required
parameter is missing: grant_type"
When I inspect the error message in Firebug, it says that the "Post"
is:
grant_type=authorization_code&client_id=...&client_secret=...&code=...&redirect_uri=urn:ietf:wg:oauth:
2.0:oob
Thus, I am fairly sure that
a) I am making a POST request
b) I am including the grant_type header
Simplified code: (javascript)
var req = new XMLHttpRequest();
var tokenUrl = "
https://accounts.google.com/o/oauth2/
token";
var clientId = "..."; // From the Google API Console
var clientSecret = "..."; // From the Google API Console
var authorizationCode = "..."; // Received from the client access
token web-page
var body = "";
body += "grant_type=authorization_code&";
body += "client_id="+clientId+"&";
body += "client_secret="+clientSecret+"&";
body += "code="+authorizationCode+"&";
body += "redirect_uri=urn:ietf:wg:oauth:2.0:oob";
req.onReadyStateChange = onTokenReceivedFunction;
req.open("POST", tokenUrl, true);
req.send(body);
The request headers:
Host
accounts.google.com
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0)
Gecko/20100101 Firefox/4.0
Accept text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Content-Length 193
Content-Type text/plain; charset=UTF-8
Origin null
The response headers:
Cache-Control no-cache, no-store, max-age=0, must-
revalidate
Pragma no-cache
Expires Fri, 01 Jan 1990 00:00:00 GMT
Date Tue, 26 Apr 2011 02:32:33 GMT
Content-Type text/html; charset=UTF-8
Content-Encoding gzip
X-Content-Type-Options nosniff
X-Frame-Options SAMEORIGIN
X-XSS-Protection 1; mode=block
Content-Length 150
Server GSE