Frido1 Frido1 - 11 months ago 97
AngularJS Question

Required Parameter is missing grant_type Google oauth2.0 AngularJS and Cordova inappbrowser

I am using Cordova's inappbrowser and integrating Google oauth2.0. Once I get the authorization code I make a post request to get my token. NO MATTER what I try I always get a 400 error with "Required Parameter is missing grant_type". I'm encoding uri, I'm setting the right headers but to no avail... can anyone help?

method: 'POST',
url: '',
}).error(function(data, status,headers,config){
console.log('data, status, headers,config',data,status,headers,config);

and this is the output from the Chrome dev Console when I try to make the request

enter image description here

Request URL:

Request Method:POST

Status Code:400 Bad Request

Request Headers


Accept: application/json, text/plain, /

Origin: file://

testing: testing

User-Agent: Mozilla/5.0 (Linux; Android 4.4.2; SCH-I535 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/ Mobile Safari/537.36

Query String Parameters

Response Headers
HTTP/1.1 400 Bad Request
Pragma: no-cache
Date: Mon, 14 Jul 2014 06:35:22 GMT
Content-Encoding: gzip
X-Content-Type-Options: nosniff
Server: GSE
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Transfer-Encoding: chunked
Alternate-Protocol: 443:quic
X-XSS-Protection: 1; mode=block
Expires: Fri, 01 Jan 1990 00:00:00 GMT

Answer Source

Wrong post request. The params property is used to set any additional request parameters to be appended to the URL query string. The params property is a JavaScript object with one property per request parameter to add.

Here for your reference.