-
Notifications
You must be signed in to change notification settings - Fork 310
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
AttributeError in credentials.py #405
Comments
@ryoichitaniguchi thanks for the suggestion - rolling back to google-auth==1.7.2 workarounded for me |
@maxiller @ryoichitaniguchi Were you using a pickled credential file? Please do continue to use the downgraded version 1.7.2 - we will release a patch version soon with a fix. Thank you for your patience |
The Docs API quickstart is representative of the sample style for APIs requiring user credentials. It pickles the credentials after the first run and reloads them when available. from __future__ import print_function
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/documents.readonly']
# The ID of a sample document.
DOCUMENT_ID = '195j9eDD3ccgjQRttHhJPymLJUCOUjs-jmwTrekvdjFE'
def main():
"""Shows basic usage of the Docs API.
Prints the title of a sample document.
"""
creds = None
# The file token.pickle stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials.json', SCOPES)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
service = build('docs', 'v1', credentials=creds)
# Retrieve the documents contents from the Docs service.
document = service.documents().get(documentId=DOCUMENT_ID).execute()
print('The title of the document is: {}'.format(document.get('title')))
if __name__ == '__main__':
main() |
damn! Thought something happen to my code! |
I created new credentials based on the old one:
Then I did pickle again to file |
Hi - If you're running into this, please do either (1) or (2). (1) Delete your pickled credentials file. The file will be named |
(1) did the trick. Thanks! |
worked with |
Closing as the latest published library should work correctly with older pickled credentials files. |
I am unable to install gspread with python 3.9.12 version, it throws error "module 'google.auth.credentials' has no attribute 'CredentialsWithTokenUri' " |
Hello,
after updating
google-auth
package fromv1.7.2
tov1.8.0
error occurred fromcredentials.py
stack-trace:
Trigger is googleapiclient.http.execute():
Downgrading google-auth to previous version (or avoid to refer this attribute) , error dissapeared.
Some compatibility issue behind this? Appreciate if someone let me know..
requirements condition
installed version from pip-list
The text was updated successfully, but these errors were encountered: