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

Add logging to create_access_token_credential #991

Open
stepancheg opened this issue Feb 5, 2025 · 1 comment
Open

Add logging to create_access_token_credential #991

stepancheg opened this issue Feb 5, 2025 · 1 comment
Labels
auth Issues related to the auth library priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@stepancheg
Copy link

stepancheg commented Feb 5, 2025

This is a small feature request. Feel free to close if not important/already planned/too hard/etc.

Is your feature request related to a problem? Please describe.

When auth doesn't work, error message is not always helpful: some error from HTTP service.

called `Result::unwrap()` on an `Err` value: CredentialError { is_retryable: false, source: "Failed to fetch token. {\n  \"error\": \"invalid_grant\",\n  \"error_description\": \"reauth related error (invalid_rapt)\",\n  \"error_uri\": \"https://support.google.com/a/answer/9368756\",\n  \"error_subtype\": \"invalid_rapt\"\n}" }thread 'tests::test2' panicked at xxx/src/lib.rs:9:55:

Turns out my local gcloud login expired. But at the time I was not even sure, that it actually used auth provided by gcloud command (file ~/.config/gcloud/application_default_credentials.json).

Describe the solution you'd like

Add debug statements how authentication was obtained, for example:

logging::debug!("ADC path found using well known path: {}", adc_path);
...
logging::debug!("Calling URL https://... to obtain token ...")

Ideally, produce error message not just with final http response, but also with information

  • why this URL was called
  • suggestion to re-run gcloud auth login gcloud auth application-default login if something is expired and needs renewing

(I am a new user of GCP, so don't know well how it works.)

Describe alternatives you've considered

Invoke gcloud auth application-default print-access-token command directly, or call https://metadata.google.internal/... directly, as it is easier to debug.

@stepancheg stepancheg added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Feb 5, 2025
@coryan coryan added the auth Issues related to the auth library label Feb 5, 2025
@coryan
Copy link
Contributor

coryan commented Feb 5, 2025

Thanks for the detailed bug report. Tagging #838 because there is some overlap with that feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues related to the auth library priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants