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

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

Closed
Fkawala opened this issue Dec 7, 2016 · 8 comments
Closed

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

Fkawala opened this issue Dec 7, 2016 · 8 comments
Assignees
Labels

Comments

@Fkawala
Copy link

Fkawala commented Dec 7, 2016

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.

@Fkawala
Copy link
Author

Fkawala commented Dec 7, 2016

To downgrade google-cloud-core to version 0.21.0 "solves" the problem.

@daspecster daspecster added the auth label Dec 7, 2016
@theacodes
Copy link
Contributor

@dhermes this is why we released 0.21.1, right?

@dhermes
Copy link
Contributor

dhermes commented Dec 7, 2016

@jonparrott beat me to it @Fkawala. I stupidly relesed 0.21.0 without version upper bounds, so 0.21.1 is the exact same release, except putting upper bounds on the subpackages (and bumping the version for HappyBase, which is also the same code).

#2828 will at least improve the messaging.

@dhermes dhermes closed this as completed Dec 7, 2016
@PLPeeters
Copy link

This issue is present again with version 0.27.0. Downgrading to 0.26.1 solves the issue.

@Fkawala
Copy link
Author

Fkawala commented Aug 31, 2017

@PLPeeters ditto !

@viyh
Copy link

viyh commented Sep 15, 2017

+1

william-silversmith added a commit to seung-lab/cloud-volume that referenced this issue Oct 27, 2017
Resolves this issue: googleapis/google-cloud-python#2832

"AttributeError: 'Credentials' object has no attribute 'authorize"
@william-silversmith
Copy link

I'm sort of caught between a rock and a hard place. 0.26.1 is not thread safe, but works sporadically. 0.27 seems to be thread safe, but has this issue inside of docker containers for some reason. I'll report more information once I figure out the exact issue.

@william-silversmith
Copy link

FYI it looks like the issue is caused by HAS_GOOGLE_AUTH being False:

    import google.auth
    import google.auth.credentials
    import google_auth_httplib2
    HAS_GOOGLE_AUTH = True
except ImportError:  # pragma: NO COVER
    HAS_GOOGLE_AUTH = False

It can be mitigated by running pip install google-auth-httplib2. By the way, the instruction is missing the 'p' in httplib2 on this page: https://pypi.python.org/pypi/google-auth-httplib2

william-silversmith added a commit to seung-lab/python-task-queue that referenced this issue Nov 4, 2017
* feat: support more project_name specification locations for google credentials

* refactor: use cloudvolume.secrets instead of reimplementing it

* fix: trying to solve Credentials' object has no attribute 'authorize'

googleapis/google-cloud-python#2832
william-silversmith added a commit to seung-lab/cloud-volume that referenced this issue Jan 18, 2018
Resolves this issue: googleapis/google-cloud-python#2832

"AttributeError: 'Credentials' object has no attribute 'authorize"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants