Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Sign In button setScopes() deprecated

Today I have upgraded my play service dependency to compile 'com.google.android.gms:play-services-auth:10.0.1'. Now I am seeing that setScopes has been deprecated.

private GoogleApiClient mGoogleApiClient;
private GoogleSignInOptions gso;


gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .build();
mGoogleApiClient = new GoogleApiClient.Builder(mContext)
            .enableAutoManage(this, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
btnGoogleSignIn.s̶e̶t̶S̶c̶o̶p̶e̶s̶(gso.getScopeArray());

now what is alternative for this. how to set scopes ??

like image 609
Abhishek Singh Avatar asked May 09 '26 12:05

Abhishek Singh


1 Answers

You don't need to set scopes on the button any more, as the button no longer depends on the scopes used. In the past, the button used to be a red G+ Sign-In button if plus.login scope was used and a G+ Account was required. There is no more Google+ Account requirement anymore. For more info, see https://developers.googleblog.com/2016/11/moving-to-google-sign-in-for-a-better-user-experience-and-higher-conversion-rates.html

If you'd like to request additional scopes, do so in context when you need access to the specific data (e.g. calendar / contacts) and explain to the user why you will be prompting them (the same UX patterns as runtime permissions for Marshmallow+ devices and iOS) and use requestScopes when building the GoogleSignInOptions for your sign-in request. See https://developers.google.com/identity/sign-in/android/additional-scopes for more information.

like image 127
Steven Avatar answered May 12 '26 01:05

Steven



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!