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

An error occurs when creating the cloud logging client #953

Closed
jaeseunglee opened this issue May 19, 2017 · 1 comment
Closed

An error occurs when creating the cloud logging client #953

jaeseunglee opened this issue May 19, 2017 · 1 comment

Comments

@jaeseunglee
Copy link

I would like to use the following method without setting environment variables.

from google.cloud import logging
client = logging.Client.from_service_account_json(path of credentials.json)

However, the following error occurs.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/client.py", line 72, in from_service_account_json
    return cls(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/logging/client.py", line 107, in __init__
    project=project, credentials=credentials, _http=_http)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/client.py", line 213, in __init__
    _ClientProjectMixin.__init__(self, project=project)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/client.py", line 169, in __init__
    project = self._determine_default(project)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/client.py", line 182, in _determine_default
    return _determine_default_project(project)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/_helpers.py", line 181, in _determine_default_project
    _, project = google.auth.default()
  File "/usr/local/lib/python2.7/dist-packages/google/auth/_default.py", line 285, in default
    raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or
explicitly create credential and re-run the application. For more
information, please see
https://developers.google.com/accounts/docs/application-default-credentials.

Is there a way to use without errors?

I do not want to use environment variables, but I want to use the credentials file directly when creating a Client object.

@theacodes
Copy link
Contributor

I think you need to also pass in the project explicitly in this case. See googleapis/google-cloud-python#1883.

For what it's worth, we highly recommend using the environment variable.

Closing, but please comment if that isn't the solution to your problem).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants