google-app-enginegoogle-apigoogle-oauthgoogle-docs-api

AttributeError("'Credentials' object has no attribute 'request'")


Our application has to create / write a Google doc using Google Doc APIs. Based on documentation here , we 1) Enabled our API in the Google Cloud Console. We then define the Scope of the API call.

self.GOOGLEDOCUMENTS_SCOPES = ['https://www.googleapis.com/auth/spreadsheets','https://www.googleapis.com/auth/documents','https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/drive.file']

We then create the credentials

document_credentials, document_project_id     = auth.default(scopes=self.GOOGLEDOCUMENTS_SCOPES)

We then build the discover service

document_service                = build('docs', 'v1', self.document_credentials)

We then call the api to create the google doc.

document_service.documents().create(body=body).execute()

We get the following error -

AttributeError("'Credentials' object has no attribute 'request'")

Solution

  • In your showing script, how about the following modification?

    From:

    document_service                = build('docs', 'v1', self.document_credentials)
    

    To:

    document_service = build('docs', 'v1', credentials=self.document_credentials)