-
Notifications
You must be signed in to change notification settings - Fork 52
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
base: main
Are you sure you want to change the base?
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
@@ -175,9 +176,19 @@ public static ClientContext create(StubSettings settings) throws IOException { | |||
// A valid EndpointContext should have been created in the StubSettings | |||
EndpointContext endpointContext = settings.getEndpointContext(); | |||
String endpoint = endpointContext.resolvedEndpoint(); | |||
String apiKey = settings.getApiKey(); | |||
Credentials credentials = settings.getCredentialsProvider().getCredentials(); | |||
if (apiKey != null && credentials != null) { |
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 added logic here to handle null check snd setting credentials (instead of in builder) as I thought it would be more discoverable/debuggable here since the rest of credential logic lives here
throw new IllegalArgumentException("The GDC-H API audience string is not a valid URI", ex); | ||
} | ||
credentials = ((GdchCredentials) credentials).createWithGdchAudience(gdchAudienceUri); | ||
credentials = getGdchCredentials(settingsGdchApiAudience, endpoint, credentials); |
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.
created helper method for readability, no change to logic
Allow gax client libraries to authenticate using API key via setApiKey method exposed from ClientSettings.
Tested using LanguageServiceSettings