-
Notifications
You must be signed in to change notification settings - Fork 36
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 HttpClient based implementation of HttpTransportFactory #1015
Conversation
An implementation of the GCP SDK API `HttpTransportFactory` is added that internally uses the default Micronaut `HttpClient`. This API is used by the GCP `GoogleCredentials` for refreshing OAuth tokens for use in API calls. This implementation adds enhanced logging of token refresh requests that is useful in debugging misconfigured credentials. Using the default `HttpClient` also allows the potential for setting timeouts and other such properties via typical Micronaut configuration. The implementation uses the blocking version of the `HttpClient` API. This is safe to use in this case as the GCP library is already executing these tasks using its own managed threads, so these requests should not block the main Micronaut event loop. The implementation is only activated if `HttpClient` is found to be on the classpath. If it is not, the default implementation provided by the SDK will be used instead.
gcp-common/src/test/groovy/io/micronaut/gcp/credentials/GoogleCredentialsFactorySpec.groovy
Outdated
Show resolved
Hide resolved
Co-authored-by: Tim Yates <tim.yates@gmail.com>
@jeremyg484 can you merge master into this? |
Done. |
@@ -111,4 +119,11 @@ public void close() throws Exception { | |||
} | |||
} | |||
} | |||
|
|||
boolean isRunning(ProjectSubscriptionName subscriptionName) { |
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.
It is weird to expose a method only to be used in a test.
gcp-common/src/main/java/io/micronaut/gcp/credentials/GoogleCredentialsFactory.java
Show resolved
Hide resolved
gcp-common/src/main/java/io/micronaut/gcp/credentials/GoogleCredentialsConfiguration.java
Show resolved
Hide resolved
gcp-common/src/main/java/io/micronaut/gcp/credentials/DefaultOAuth2HttpTransportFactory.java
Show resolved
Hide resolved
gcp-common/src/main/java/io/micronaut/gcp/credentials/OAuth2MessageBodyWriter.java
Show resolved
Hide resolved
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 5 New issues |
An implementation of the GCP SDK API
HttpTransportFactory
is added that internally uses the default MicronautHttpClient
. This API is used by the GCPGoogleCredentials
for refreshing OAuth tokens for use in API calls. Thisimplementation adds enhanced logging of token refresh requests that is useful in debugging misconfigured
credentials. Using the default
HttpClient
also allows the potential for setting timeouts and other such propertiesvia typical Micronaut configuration.
The implementation uses the blocking version of the
HttpClient
API. This is safe to use in this case as the GCPlibrary is already executing these tasks using its own managed threads, so these requests should not block the main
Micronaut event loop.
The implementation is only activated if
HttpClient
is found to be on the classpath. If it is not, the defaultimplementation provided by the SDK will be used instead.
This is initially most useful as a replacement for the enhanced logging that was being done in the problematic
AuthenticationLoggingInterceptor
. As the tests show, this approach allows theGoogleCredentials
API to still be used to its full extent by end users as needed.