Skip to content

AttributeError: 'Credentials' object has no attribute 'authorize' #2832

@Fkawala

Description

@Fkawala

Hello,

To run this snippet :

import google
import google.cloud.logging
import google.cloud.logging.handlers 

client = google.cloud.logging.Client()
handler = google.cloud.logging.handlers.CloudLoggingHandler(client=client, name="xyz")

Fails as follow

Traceback (most recent call last):
  File "s.py", line 6, in <module>
    handler = google.cloud.logging.handlers.CloudLoggingHandler(client=client, name="xyz")
  File "/path/to/venv/lib/python3.5/site-packages/google/cloud/logging/handlers/handlers.py", line 80, in __init__
    self.transport = transport(client, name)
  File "/path/to/venv/lib/python3.5/site-packages/google/cloud/logging/handlers/transports/background_thread.py", line 154, in __init__
    http = client._connection.credentials.authorize(http)
AttributeError: 'Credentials' object has no attribute 'authorize'

I test this in a fresh virtualenv whose freeze shows

enum34==1.1.6
future==0.16.0
gapic-google-logging-v2==0.10.1
google-auth==0.4.0
google-auth-httplib2==0.0.2
google-cloud-core==0.22.0
google-cloud-logging==0.21.0
google-gax==0.14.1
googleapis-common-protos==1.5.0
grpc-google-logging-v2==0.10.1
grpcio==1.0.1
httplib2==0.9.2
oauth2client==4.0.0
ply==3.8
protobuf==3.1.0.post1
pyasn1==0.1.9
pyasn1-modules==0.0.8
rsa==3.4.2
six==1.10.0

pip show google-cloud-logging shows

Name: google-cloud-logging
Version: 0.21.0
Summary: Python Client for Stackdriver Logging
Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python
Author: Google Cloud Platform
Author-email: jjg+google-cloud-python@google.com
License: Apache 2.0
Location: /path/to/venv/lib/python3.5/site-packages
Requires: google-gax, gapic-google-logging-v2, grpc-google-logging-v2, grpcio, google-cloud-core

and pip show google-cloud-core shows

Name: google-cloud-core
Version: 0.22.0
Summary: API Client library for Google Cloud: Core Helpers
Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python
Author: Google Cloud Platform
Author-email: jjg+google-cloud-python@google.com
License: Apache 2.0
Location: /path/to/venv/lib/python3.5/site-packages
Requires: protobuf, google-auth-httplib2, six, httplib2, google-auth, googleapis-common-protos

I do this test in a blank directory with only the json credentials and the above mentioned script. To run the snippet I do GCLOUD_PROJECT=my-project GOOGLE_APPLICATION_CREDENTIALS=my-cred.json python snippet.py

Could it had something to do with the new version of google-cloud-core (0.22.0 published 2016-12-06) ?

Bests,
François.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions