I am using Google oAuth along with ngCordova. While I am able to retrieve access_token, the subsequent call to get refresh_token is failing. Here is my request.
I have ensured that
Here is the Javascript code
var clientSecret = encodeURI(result["access_token"]);
var req = {
method: "POST",
url:"https://accounts.google.com/o/oauth2/token",
headers:{
"Content-Type":"application/x-www-form-urlencoded"
},
data : {"code":clientSecret,"client_id":"XXXXX","client_secret":"XXX",
"redirect_uri":"","grant_type":"authorization_code",scope:""}
};
$http(req).success(...).error(...);
Please someone tell me what I am doing wrong.
My Bad, the problem was with the authentication approach chosen by me. I was using ngCordova to invoke google authentication flow, which sets response_type
to token
. In my case, since I was expecting refresh token
to be created once user authorizes app, the response_type
was supposed to be set to code
.
I modified the code and it worked.