Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oauth2client deprecated #41

Open
dotysan opened this issue Jun 22, 2018 · 3 comments
Open

oauth2client deprecated #41

dotysan opened this issue Jun 22, 2018 · 3 comments

Comments

@dotysan
Copy link

dotysan commented Jun 22, 2018

Symptom

Nowadays pip install --upgrade google-api-python-client PyOpenSSL will cause our script to fail like this:

Traceback (most recent call last):
  File "./import-mailbox-to-gmail.py", line 36, in <module>
    from oauth2client.service_account import ServiceAccountCredentials
ImportError: No module named oauth2client.service_account

Cause

The google-api-client no longer requires/installs oauth2client package.

Workaround

pip install --upgrade google-api-python-client PyOpenSSL oauth2client

Discussion

https://google-auth.readthedocs.io/en/latest/oauth2client-deprecation.html

It looks like oauth2client.service_account.ServiceAccountCredentials.from_json_keyfile_name() has moved to google.oauth2.service_account.Credentials.from_service_account_file() but the new Credentials class doesn't define an authorize() function. It appears we'll need to use google_auth_httplib2.AuthorizedHttp(credentials) instead. But I'm not sure.

Additionally, I can't find any replacement for oauth2client.tools.argparser so I guess a workaround would be to disable the inheritance of the --auth* --noauth* args? Yuk!

@andpoi
Copy link

andpoi commented Aug 5, 2019

@andpoi
Copy link

andpoi commented Aug 5, 2019

I looked for a long time to figure out this issue. My recommendation is to just use GYB with the --service-account flag

https://github.com/jay0lee/got-your-back

@renaro
Copy link

renaro commented Jan 31, 2020

I still don't know how to fix this. As @dotysan mentioned the new Credentials class does not have authorize() function. Does anybody know how to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants