Unable to customize Google login area on Android

I am using the Google API to enter the Android app.

The code is here:

SignInButton btnLogin = (SignInButton) findViewById(R.id.sign_in_button); btnLogin.setOnClickListener(this); Scope[] scopes = new Scope[2]; scopes[0] = new Scope("https://www.googleapis.com/auth/admin.directory.user.readonly"); scopes[1] = new Scope("https://www.googleapis.com/auth/contacts.readonly"); btnLogin.setScopes(scopes); 

Enter success with an access token , but access tokens are only by default:

 "userinfo.profile" & "userinfo.email" & "auth/plus.me" 

Can you help me get 2 areas:

 "/auth/admin.directory.user.readonly" & "/auth/contacts.readonly" 
+5
source share
2 answers

You can refer to the following syntax:

 GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(new Scope(Scopes.PLUS_LOGIN)) // "https://www.googleapis.com/auth/plus.login" .requestScopes(new Scope(Scopes.PLUS_ME)) // "https://www.googleapis.com/auth/plus.me" .requestEmail() .build(); 

Learn more about this documentation . Hope this helps!

+17
source

You can add multiple areas in requestScopes ().

 GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(new Scope(Scopes.PLUS_LOGIN), new Scope(Scopes.PLUS_ME)) .requestEmail() .build(); 
+1
source

Source: https://habr.com/ru/post/1240220/


All Articles