GoogleCredentials Deprecated but is still used as an example for authentication
See original GitHub issueHi Admin,
GoogleCredentials has already been deprecated but is still being used as an example in the Authentication using OAuth2. Would like to use the more updated version. Hope there will be some update. Thanks! 😃
If you already have an OAuth2 access token, you can use it to authenticate (notice that in this case, the access token will not be automatically refreshed):
Storage storage = StorageOptions.newBuilder()
.setCredentials(new GoogleCredentials(new AccessToken(accessToken, expirationTime)))
.build()
.getService();
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
What is the alternative to the deprecated 'GoogleCredential'?
After a while of looking around, I managed to fix it, using GoogleCredentials and HttpRequestInitializer . The code changes are as follows.
Read more >GoogleCredential deprecated, new example please
But the Class GoogleCredential (from com.google.api.client.googleapis.auth.oauth2.GoogleCredential) is deprecated since a couple of months.
Read more >Class GoogleCredential (2.1.1) | Java client library
Deprecated. Please use google-auth-library for handling Application Default Credentials and other non-OAuth2 based authentication.
Read more >oauth2client deprecation — google-auth 1.30.0 documentation
Clear purpose and goals: google-auth is explicitly focused on Google-specific authentication, especially the server-to-server (service account) use case.
Read more >GoogleCredential (google-api-client 1.33.2) - javadoc.io
Deprecated. Please use google-auth-library for handling Application Default Credentials and other non-OAuth2 based authentication.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@adelbenhamadi Actually, replacing this:
With this:
GoogleCredential
to go away. How come? The only one that seem deprecated now isContactsService.setOAuth2Credentials(GoogleCredential)
.I don’t see it can easily be replaced. My current code is very similar to this one:
https://github.com/simformsolutions/Google-People-API-Sample/blob/master/app/src/main/java/com/simform/peoples/PeopleHelper.java
Meaning:
How could I change it? Even replacing
GoogleCredential
withGoogleCredentials
produces various issues…@cyrilfr Is it now suitable even for the code snippet I wrote?
Can you please share the code you’ve used? How did you find “getTokenValue” for GoogleTokenResponse instance, for example? I don’t see it…