Subhankar Chakraborty
Subhankar Chakraborty

Reputation: 179

cannot import name 'external_account_authorized_user' from 'google.auth'

from pprint import pprint
from Goo_gle import Create_Service


CLIENT_SECRET_FILE = 'Client_Calendar.json'
API_NAME = 'calendar'
API_VERSION = 'v3'
SCOPES = ['https://www.googleapis.com/auth']


service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES)

Output:

Traceback (most recent call last):   File "d:\Play with code\PROGRAMMINGS\Python\Artificial Inteligence\calen_dar.py", line 2, in <module>
    from Goo_gle import Create_Service   File "d:\Play with code\PROGRAMMINGS\Python\Artificial Inteligence\Goo_gle.py", line 5, in <module>
    from google_auth_oauthlib.flow import Flow, InstalledAppFlow   File "C:\Python\lib\site-packages\google_auth_oauthlib\__init__.py", line 21, in <module>
    from .interactive import get_user_credentials   File "C:\Python\lib\site-packages\google_auth_oauthlib\interactive.py", line 27, in <module>
    import google_auth_oauthlib.flow   File "C:\Python\lib\site-packages\google_auth_oauthlib\flow.py", line 69, in <module>
    import google_auth_oauthlib.helpers   File "C:\Python\lib\site-packages\google_auth_oauthlib\helpers.py", line 27, in <module>
    from google.auth import external_account_authorized_user ImportError: cannot import name 'external_account_authorized_user' from 'google.auth' (C:\Python\lib\site-packages\google\auth\__init__.py)

I am not getting why this is happening. This code was working from last 3 month but today after updating google libraries, this error came.. How to fix this?

Upvotes: 14

Views: 11825

Answers (4)

Kiran Sk
Kiran Sk

Reputation: 933

Check the version of google-auth: It seems that the version of google-auth installed in your virtual environment might be outdated or incompatible. Try upgrading the google-auth package by running:

pip install --upgrade google-auth google-auth-oauthlib

Upvotes: 0

Vu Phan
Vu Phan

Reputation: 584

You will get that error when using google_auth_oauthlib as the latest version (0.6.0). Refer to this link: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/v0.6.0/google_auth_oauthlib/helpers.py#L27

Try to downgrade google-auth-oauthlib lib by using this command: pip install google-auth-oauthlib==0.4.6

or update your requirement.txt to add this line:

...
google-auth-oauthlib==0.4.6
...

Upvotes: 9

Seregon
Seregon

Reputation: 11

Downgrade google-auth-oauthlib==0.6.0 (released yesterday) to 0.5.3 has solved my problem. Thank's to @Samik

Upvotes: 1

Steve Pike
Steve Pike

Reputation: 1544

Looks to be related to a recent change in the google-auth-library-python-oauth module:

https://github.com/googleapis/google-auth-library-python-oauthlib/pull/240/files#diff-63cdf7d9059947cf2f03b72a8137b8a1901de52f685705c251886d58a75b9381L8

Upgrading google-auth to 2.13.0 may fix it.

Upvotes: 14

Related Questions