feat(auth): allow consuming access tokens directly#3642
feat(auth): allow consuming access tokens directly#3642alvarowolfx merged 15 commits intogoogleapis:mainfrom
Conversation
|
This is a WIP and is missing all documentation for the new interface. Pros:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3642 +/- ##
=======================================
Coverage 95.02% 95.03%
=======================================
Files 161 161
Lines 6049 6097 +48
=======================================
+ Hits 5748 5794 +46
- Misses 301 303 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I don't know what is the exact level of test coverage we want, but 46% is too low. |
this is also missing tests, is just a draft for the public API. |
dbolduc
left a comment
There was a problem hiding this comment.
FWIW, this approach makes a lot of sense to me. It is lamentable that we are already making backwards compatibility sacrifices in version 1.1.0 of a library, but that is where we are.
I think I messed up by making Credentials an opaque object instead of a trait. I think at the time I was afraid of all the generics that entailed... but now I realize that is just what flexible Rust looks like.
|
Marking as draft. If / when it is ready for review please let us know. |
@coryan it was ready to review, but I think I'll split into smaller PRs to make it easier to review. Unless you think this is in a reasonable size. |
|
@dbolduc can you take another look? |
dbolduc
left a comment
There was a problem hiding this comment.
The code looks really good, and I would symbolically approve the PR. I think my comments are mostly grammar nits.
I need an explicit answer on why we are abandoning Extensions / CacheableResource for the AccessToken before I can approve though.
src/auth/src/credentials.rs
Outdated
| Ok(self.build_access_token_credentials()?.into()) | ||
| } | ||
|
|
||
| /// Returns a [Credentials] instance with the configured settings. |
There was a problem hiding this comment.
nit: s/Credentials/AccessTokenCredentials/
src/auth/src/credentials.rs
Outdated
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns a [CredentialsError] if a unsupported credential type is provided |
There was a problem hiding this comment.
nit: s/a unsupported/an unsupported/
src/auth/src/credentials.rs
Outdated
| /// Returns a [CredentialsError] if a unsupported credential type is provided | ||
| /// or if the JSON value is either malformed | ||
| /// or missing required fields. For more information, on how to generate | ||
| /// json, consult the relevant section in the [application-default credentials] guide. |
There was a problem hiding this comment.
nit: s/json/the JSON for a credential/ ?
| Ok(self.build_access_token_credentials()?.into()) | ||
| } | ||
|
|
||
| /// Returns a [AccessTokenCredentials] instance with the configured settings. |
| /// Returns a [BuilderError] if the `external_account_config` | ||
| /// provided to [`Builder::new`] cannot be successfully deserialized into the | ||
| /// expected format for an external account configuration. This typically happens if the | ||
| /// JSON value is malformed or missing required fields. For more information, | ||
| /// on the expected format, consult the relevant section in the | ||
| /// [external_account_credentials] guide. |
There was a problem hiding this comment.
nit: reflow?
we do not have any sort of tool. I just manully cut lines off at or before 80 characters. 🤷
Also consider a paragraph break before "For more information..."
src/auth/src/credentials.rs
Outdated
| /// | ||
| /// Returns a [CredentialsError] if a unsupported credential type is provided | ||
| /// or if the JSON value is either malformed | ||
| /// or missing required fields. For more information, on how to generate |
There was a problem hiding this comment.
optional nit: paragraph break before "For more information..."
pushed some updates addressing the nits in the docs and also made some improvements so customers can mock the new trait |
Fixes #2929 and #3362