cordova-plugin-googleplus
cordova-plugin-googleplus copied to clipboard
Not retrieving data from optional scopes
Hi, I'm trying to retrieve the user phone numbers using this scope: https://www.googleapis.com/auth/contacts.readonly. But what I'm getting is the default data from profile and email and nothing else. I searched everywhere looking for examples using scopes and the response data but I didn't find it. I already enabled People and Contacts API in my project Developer's Console. I read the docs, but I didn't understand what I have to do in this part: "Additional user information is available by use case. Add the scopes needed to the scopes option then return the info to the result object being created in the handleSignInResult and didSignInForUser functions on Android and iOS, respectively". Am I doing something wrong?
JS:
window.plugins.googleplus.login(
{
'scopes': 'https://www.googleapis.com/auth/user.phonenumbers.read',
'webClientId': '<my-client-id>.apps.googleusercontent.com',
'offline': true
},
function (obj) {
console.log(obj);
},
function (msg) {
alert('error: ' + msg);
}
);
Log:

have you could solve this?
Hi @jffs and @Lucaro-P just in case you never solved the problem, or for someone else looking to do this, the explanation in the docs about the "handleSignInResult and didSignInForUser" it's just an explanation of how the plugin handles the request of the additional information. The plugin it self does not return more info, because the google SigIn doesn't.
What you have to do is request in the sigIn the scopes you want so you get permission to request that info, then you can use the existing Apis "https://developers.google.com/identity/protocols/googlescopes" to request that info through a HTTP-GET request.
For example, I was trying to retrieve birthday and gender, so you would use this API: "https://developers.google.com/people/api/rest/v1/people/get?apix_params=%7B%22resourceName%22%3A%22people%2Fme%22%2C%22personFields%22%3A%22birthdays%2Cgenders%2Cnicknames%22%7D". You can even try in the side to request all the info and see it works.
Hope it helps! ;)
Hi @jffs and @Lucaro-P just in case you never solved the problem, or for someone else looking to do this, the explanation in the docs about the "handleSignInResult and didSignInForUser" it's just an explanation of how the plugin handles the request of the additional information. The plugin it self does not return more info, because the google SigIn doesn't.
What you have to do is request in the sigIn the scopes you want so you get permission to request that info, then you can use the existing Apis "https://developers.google.com/identity/protocols/googlescopes" to request that info through a HTTP-GET request.
For example, I was trying to retrieve birthday and gender, so you would use this API: "https://developers.google.com/people/api/rest/v1/people/get?apix_params=%7B%22resourceName%22%3A%22people%2Fme%22%2C%22personFields%22%3A%22birthdays%2Cgenders%2Cnicknames%22%7D". You can even try in the side to request all the info and see it works.
Hope it helps! ;)
how can use it please provide example