I'm building a system which people can authenticate to read their gmail. I've got it working perfectly well on my website using OAuth2 in Python; in the response from google I get an access_token
, a token_type
, an expires_in
and (most importantly) a refresh_token
.
I now want to get the same working in Javascript (for an app I'm building using Ionic). So I use ngCordovaOauth to authenticate with the following code:
$cordovaOauth.google(
'xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com',
['https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/gmail.readonly'],
{
'access_type': 'offline',
'approval_prompt': 'force'
}
)
.then(function(result){
console.log("Response object -> " + JSON.stringify(result));
}, function(error){
console.log('Error -> ' + error);
});
As expected, this produces the following screen on my phone:
But in the json I get back there is no refresh_token
:
{"access_token":"xxxx.xxxxxxxxxxxx","token_type":"Bearer","expires_in":"3599"}
Does anybody know why I don't get the refesh_token
when using the Javascript api? All tips are welcome!