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

fix: use gcloud creds flow if explicit file path is set to gcloud adc path #705

Merged
merged 2 commits into from Feb 25, 2021

Conversation

arithmetic1728
Copy link
Contributor

If user doesn't set GOOGLE_APPLICATION_CREDENTIALS path, then project id can be obtained.

user@hostname:~/tmp $ python -c 'from google.auth import default; print(default())'
(<google.oauth2.credentials.Credentials object at 0x7f44b8f8eba8>, 'correct-project-id')

If user sets GOOGLE_APPLICATION_CREDENTIALS path to gcloud adc path, then project id can not be obtained. In this case, we should fall back to gcloud creds flow in the google.auth._default logic, so project id can be obtained via gcloud.

user@hostname:~/tmp $ GOOGLE_APPLICATION_CREDENTIALS=~/.config/gcloud/application_default_credentials.json python -c 'from google.auth import default; print(default())'
(<google.oauth2.credentials.Credentials object at 0x7fc3505a9b70>, None)

@arithmetic1728 arithmetic1728 requested a review from a team as a code owner February 17, 2021 20:46
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Feb 17, 2021
@arithmetic1728 arithmetic1728 merged commit 333cb76 into master Feb 25, 2021
This was referenced Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants