Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Creating Client from explicit credentials requires passing project #93

Copy link
Copy link

Description

@offlinemark
Issue body actions

Thanks for stopping by to let us know something could be better!

Environment details

  • OS type and version: mac 10.14.6
  • Python version: python --version 3.7.6
  • pip version: pip --version 20.0.2
  • google-cloud-storage version: pip show google-cloud-storage 1.26.0

Steps to reproduce

Creating a Client using an explicit credentials object fails if the project parameter is not explicitly given. Since the project id should also be available from the credentials object, this should not be required of the caller.

The docs advertise an API where the project is not passed.
https://googleapis.dev/python/google-api-core/latest/auth.html#explicit-credentials

context: I'm trying to use GCS from heroku, where configuration is more easily done via env variables than the filesystem.

thanks!

Code example

import os
import json

from google.cloud import storage
from google.oauth2 import service_account

# env contains contents json keyfile
cred = os.environ['GCP_CRED']

c = json.loads(cred)
cred = service_account.Credentials.from_service_account_info(c)

# client = storage.Client(credentials=cred) # fails
client = storage.Client(project=c['project_id'], credentials=cred) # works

print(list(client.list_buckets()))

output

google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

Reactions are currently unavailable

Metadata

Metadata

Labels

api: storageIssues related to the googleapis/python-storage API.Issues related to the googleapis/python-storage API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.