oauth2client is deprecated, can we use its replacement, google-auth?
See original GitHub issueEnvironment info
Operating System: osx Python version: 3.6 gspread version: latest
Steps to reproduce
Oauth2client documentation says it’s deprecated and we should be using google-auth
If you try to establish credentials with
credentials = service_account.Credentials.from_service_account_file(
'service-account.json')
gc = gspread.authorize(credentials)
You’ll get this error:
Traceback (most recent call last):
File "spreadsheet.py", line 19, in <module>
gc = gspread.authorize(credentials)
File "/usr/local/lib/python3.6/site-packages/gspread/client.py", line 402, in authorize
client.login()
File "/usr/local/lib/python3.6/site-packages/gspread/client.py", line 56, in login
if not self.auth.access_token or \
AttributeError: 'Credentials' object has no attribute 'access_token'
Obviously, the google creditials json file doesn’t have an ‘access_token’ key, so something is amiss there.
If I instead use the deprecated
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('service-account.json', scope)
gc = gspread.authorize(credentials)
It works fine.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8
Top Results From Across the Web
oauth2client deprecation — google-auth 1.30.0 documentation
Instead, we've chosen to create a new replacement library that can live side-by-side with oauth2client and allow users to migrate gradually.
Read more >python - oauth2client is now deprecated - Stack Overflow
I was googling to find a solution how to replace the parts of code where oauth2client is being used. Yet since I am...
Read more >oauth2client is deprecated, can we use its replacement, google-auth?
Oauth2client documentation says it's deprecated and we should be using google-auth. If you try to establish credentials with credentials = service_account.
Read more >OAuth 2.0 for Client-side Web Applications | Authorization
This document explains how to implement OAuth 2.0 authorization to access Google APIs from a JavaScript web application.
Read more >CHANGELOG
Note: oauth2client is deprecated. No more features will be added to the libraries and the core team is turning down support. We recommend...
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 FreeTop Related Reddit Thread
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
Top GitHub Comments
if you want to integrate with google_auth, I suggest you to do with the session provided by google_auth:
refer to https://google-auth.readthedocs.io/en/latest/user-guide.html and this should work the same as before. just notice that session is from Requests and not httplib2.
@debu99 I had the same issue, and it was fixed by https://github.com/burnash/gspread/issues/664#issuecomment-574087200