Numerous API Areas Google API
I want to use multiple areas in Google's JavaScript API. I am trying to get email and username.
Name I can get from the scope: https://www.googleapis.com/auth/plus.me
And the email I can get from the area: https://www.googleapis.com/auth/userinfo.email
But how can I use them both in one application?
My code:
scopes = 'https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.email';
gapi.signin.render('StartGoogleBtn', {
'callback': 'onSignInCallback',
'clientid': clientId,
'cookiepolicy': 'single_host_origin',
'scope': scopes
});
What areas should be? Thank:)
source to share
Just guess, but try the space delimited by the double quotes surrounding it. What OAuth 2 requires, and when I wrote the code for the client, I automatically applied this script correctly. I guess this will just go through the command. This works for me.
scopes = "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.me"
source to share
I'll provide my answer by saying that I was not using the Javascript version. I am using a Java library that allows me to set scopes by passing in a list of strings containing the scopes I want.
List<String> SCOPES = Arrays.asList(
DirectoryScopes.ADMIN_DIRECTORY_GROUP, //https://www.googleapis.com/auth/admin.directory.group
DirectoryScopes.ADMIN_DIRECTORY_USER, //https://www.googleapis.com/auth/admin.directory.user
DriveScopes.DRIVE //https://www.googleapis.com/auth/drive
);
credential = new GoogleCredential.Builder()
.setTransport(httpTransport).setJsonFactory(jsonFactory)
.setServiceAccountId(serviceAccountId)
.setServiceAccountScopes(SCOPES)
.setServiceAccountPrivateKeyFromP12File(p12File)
.setServiceAccountUser(adminUser).build();
Assuming the Javascript library works similarly to Java, you should be able to add multiple scopes by turning the variable scopes
into an array of strings.
source to share