Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GoogleAuthUtil.getToken() is deprecated how can i get accessToken

I was implementing google sign but i came to this method and this is deprecated show its always return null value

String  token = GoogleAuthUtil.getToken(loginActivity, accountName, scopes);

even i used other methods

 String token = GoogleAuthUtil.getToken(loginActivity, accountName, scopes, null);

but it still returns null and shows as it is deprecated. Please help how can i get access token

like image 676
FaisalAhmed Avatar asked Sep 02 '25 16:09

FaisalAhmed


1 Answers

In the below getToken method, I think you are passing accountName which is a string value.

String  token = GoogleAuthUtil.getToken(loginActivity, accountName, scopes);
String token = GoogleAuthUtil.getToken(loginActivity, accountName, scopes, null);

thus it will still return deprecated method getToken.

converting string into account before passing as mentioned below will help`:

Account accountDetails = new Account(accountName, GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);

String  token = GoogleAuthUtil.getToken(loginActivity, accountDetails, scopes);

Hope this helps.

like image 185
Bhargavaroyal Avatar answered Sep 05 '25 14:09

Bhargavaroyal



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!