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:

And the email I can get from the area:

But how can I use them both in one application?

My code:

scopes = '';

    gapi.signin.render('StartGoogleBtn', {
      'callback': 'onSignInCallback',
      'clientid': clientId,
      'cookiepolicy': 'single_host_origin',
      'scope': scopes


What areas should be? Thank:)


source to share

2 answers

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 = ""




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, //
        DirectoryScopes.ADMIN_DIRECTORY_USER,  //
        DriveScopes.DRIVE                      //

credential = new GoogleCredential.Builder()


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.



All Articles