-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat(gax): add API key authentication to ClientSettings #3137
Conversation
🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use -- conventional-commit-lint bot |
…dentials are provided
gax-java/gax/src/main/java/com/google/api/gax/rpc/ClientContext.java
Outdated
Show resolved
Hide resolved
import io.grpc.Status; | ||
|
||
/** Implements a client interceptor to retrieve the metadata from a GRPC client request. */ | ||
public class GrpcCapturingClientInterceptor implements ClientInterceptor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I like this. I think we had this in our backlog a while back: #2743
Probably can mark this as closed once this PR is in.
gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java
Show resolved
Hide resolved
* @return list of provided headers that will be sent with GRPC call with any duplicates removed | ||
* see {@link #removeCredentialDuplicateHeaders()} | ||
*/ | ||
public Map<String, String> getHeadersWithDuplicatesRemoved() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only used in tests? If it is, we can make this package private and mark it as @VisibleForTesting
? Or we don't have to expose another method, just make removeCredentialDuplicateHeaders
package privare.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* a GDC-H audience | ||
*/ | ||
@VisibleForTesting | ||
public static GdchCredentials getGdchCredentials( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it is already marked as @VisibleForTesting
, can we make it package private as well? As long as it is public, customers may still use it, either accidentally or intentionally.
@@ -1074,4 +1072,46 @@ public void testStreamWatchdogInterval_backportMethodsBehaveCorrectly() { | |||
ct -> ct.getStreamWatchdogCheckIntervalDuration(), | |||
ct -> ct.getStreamWatchdogCheckInterval()); | |||
} | |||
|
|||
@Test | |||
public void testSetApiKey_createsApiCredentials() throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: These test methods don't have to be public
anymore after we migrated to junit 5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah thanks! done
Quality Gate passed for 'gapic-generator-java-root'Issues Measures |
Quality Gate passed for 'java_showcase_integration_tests'Issues Measures |
🤖 I have created a release *beep* *boop* --- <details><summary>2.47.0</summary> ## [2.47.0](v2.46.1...v2.47.0) (2024-10-04) ### Features * **gax:** add API key authentication to ClientSettings ([#3137](#3137)) ([df08956](df08956)) * **gax:** append cred-type header for auth metrics ([#3186](#3186)) ([ca3ec24](ca3ec24)) ### Bug Fixes * address incorrect universe domain validation when quota project id is set ([#3257](#3257)) ([6e70c37](6e70c37)), closes [#3256](#3256) * Disable automatically retrieving Universe Domain from Metadata Server ([#3272](#3272)) ([f4402bf](f4402bf)) ### Dependencies * update dependency com.fasterxml.jackson:jackson-bom to v2.18.0 ([#3248](#3248)) ([821e83d](821e83d)) * update dependency com.google.errorprone:error_prone_annotations to v2.33.0 ([#3265](#3265)) ([94450a9](94450a9)) * update dependency com.google.errorprone:error_prone_annotations to v2.33.0 ([#3266](#3266)) ([8235463](8235463)) * update dependency com.google.guava:guava to v33.3.1-jre ([#3228](#3228)) ([4e76207](4e76207)) * update dependency net.bytebuddy:byte-buddy to v1.15.3 ([#3246](#3246)) ([2aad71d](2aad71d)) * update google api dependencies ([#3242](#3242)) ([02aae9d](02aae9d)) * update google auth library dependencies to v1.28.0 ([#3267](#3267)) ([6d85864](6d85864)) * update googleapis/java-cloud-bom digest to 0cd97b7 ([#3260](#3260)) ([2d54a5d](2d54a5d)) * update grpc dependencies to v1.67.1 ([#3258](#3258)) ([e08906c](e08906c)) * update grpc dependencies to v1.67.1 in dependencies.properties ([#3279](#3279)) ([5b46e70](5b46e70)) * update junit5 monorepo to v5.11.2 ([#3276](#3276)) ([6b10f94](6b10f94)) * update netty dependencies to v4.1.114.final ([#3263](#3263)) ([8bd83d9](8bd83d9)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Allow gax client libraries to authenticate using API key via setApiKey method exposed from ClientSettings. Also added deduping to GRPC calls for api key headers.
Tested using LanguageServiceSettings
cc @westarle