Skip to content

An error occurs when creating the cloud logging client #953

Closed

Description

@jaeseunglee

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.

Activity

  1. theacodes commented on May 20, 2017

    @theacodes
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions