Retry GCE environment check for Application Default Credentials#110
Retry GCE environment check for Application Default Credentials#110tcoffee-google merged 4 commits intogoogleapis:masterfrom
Conversation
Adapt fix from Apiary client libraries. Currently untested. Addresses googleapis#109.
lukecwik
left a comment
There was a problem hiding this comment.
This looks like the changes done in the Apiary OAuth code and also addresses some other minor differences like the NO_GCE_CHECK and GCE_METADATA_HOST which aren't strictly required to fix the issue but I believe are a good idea to include in this change.
| @@ -61,6 +63,22 @@ public class ComputeEngineCredentials extends GoogleCredentials { | |||
| "http://metadata/computeMetadata/v1/instance/service-accounts/default/token"; | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @@ -61,6 +63,22 @@ public class ComputeEngineCredentials extends GoogleCredentials { | |||
| "http://metadata/computeMetadata/v1/instance/service-accounts/default/token"; | |||
| static final String METADATA_SERVER_URL = "http://metadata.google.internal"; | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| return true; | ||
| /** Return whether code is running on Google Compute Engine. */ | ||
| static boolean runningOnComputeEngine( | ||
| HttpTransportFactory transportFactory, DefaultCredentialsProvider provider) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| public static String getTokenServerEncodedUrl() { | ||
| return getMetadataServerUrl() + "/computeMetadata/v1/instance/service-accounts/default/token"; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| assertEquals(transportFactory.transport.getRequestCount(), 0); | ||
| } | ||
|
|
||
| @Test |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
LGTM |
|
When is the next scheduled release so that Apache Beam can incorporate these fixes? |
c907d69 to
791ba2c
Compare
|
This is the only update since the last release, but I wouldn't mind doing another. @lesv do you have any objection? |
Adapt fix from Apiary client libraries. Currently untested.
Addresses #109.