diff --git a/oauth2_http/java/com/google/auth/oauth2/AwsCredentials.java b/oauth2_http/java/com/google/auth/oauth2/AwsCredentials.java index 4f00517bc..25d67660d 100644 --- a/oauth2_http/java/com/google/auth/oauth2/AwsCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/AwsCredentials.java @@ -273,7 +273,7 @@ AwsSecurityCredentials getAwsSecurityCredentials() throws IOException { // Check environment variables for credentials first. String accessKeyId = getEnvironmentProvider().getEnv("AWS_ACCESS_KEY_ID"); String secretAccessKey = getEnvironmentProvider().getEnv("AWS_SECRET_ACCESS_KEY"); - String token = getEnvironmentProvider().getEnv("Token"); + String token = getEnvironmentProvider().getEnv("AWS_SESSION_TOKEN"); if (accessKeyId != null && secretAccessKey != null) { return new AwsSecurityCredentials(accessKeyId, secretAccessKey, token); } diff --git a/oauth2_http/javatests/com/google/auth/oauth2/AwsCredentialsTest.java b/oauth2_http/javatests/com/google/auth/oauth2/AwsCredentialsTest.java index 16fcb61f9..c36bdf3bc 100644 --- a/oauth2_http/javatests/com/google/auth/oauth2/AwsCredentialsTest.java +++ b/oauth2_http/javatests/com/google/auth/oauth2/AwsCredentialsTest.java @@ -276,7 +276,7 @@ void getAwsSecurityCredentials_fromEnvironmentVariablesWithToken() throws IOExce environmentProvider .setEnv("AWS_ACCESS_KEY_ID", "awsAccessKeyId") .setEnv("AWS_SECRET_ACCESS_KEY", "awsSecretAccessKey") - .setEnv("Token", "token"); + .setEnv("AWS_SESSION_TOKEN", "awsSessionToken"); AwsCredentials testAwsCredentials = (AwsCredentials) @@ -288,7 +288,7 @@ void getAwsSecurityCredentials_fromEnvironmentVariablesWithToken() throws IOExce assertEquals("awsAccessKeyId", credentials.getAccessKeyId()); assertEquals("awsSecretAccessKey", credentials.getSecretAccessKey()); - assertEquals("token", credentials.getToken()); + assertEquals("awsSessionToken", credentials.getToken()); } @Test diff --git a/oauth2_http/javatests/com/google/auth/oauth2/AwsRequestSignerTest.java b/oauth2_http/javatests/com/google/auth/oauth2/AwsRequestSignerTest.java index f7bdfb084..e43bb1dd9 100644 --- a/oauth2_http/javatests/com/google/auth/oauth2/AwsRequestSignerTest.java +++ b/oauth2_http/javatests/com/google/auth/oauth2/AwsRequestSignerTest.java @@ -535,9 +535,9 @@ public AwsSecurityCredentials retrieveAwsSecurityCredentials() throws IOExceptio GenericJson json = parser.parseAndClose(stream, StandardCharsets.UTF_8, GenericJson.class); - String awsToken = (String) json.get("Token"); - String secretAccessKey = (String) json.get("SecretAccessKey"); String accessKeyId = (String) json.get("AccessKeyId"); + String secretAccessKey = (String) json.get("SecretAccessKey"); + String awsToken = (String) json.get("Token"); return new AwsSecurityCredentials(accessKeyId, secretAccessKey, awsToken); } diff --git a/oauth2_http/javatests/com/google/auth/oauth2/ITWorkloadIdentityFederationTest.java b/oauth2_http/javatests/com/google/auth/oauth2/ITWorkloadIdentityFederationTest.java index 0683b0b5c..5ce78fcd2 100644 --- a/oauth2_http/javatests/com/google/auth/oauth2/ITWorkloadIdentityFederationTest.java +++ b/oauth2_http/javatests/com/google/auth/oauth2/ITWorkloadIdentityFederationTest.java @@ -138,7 +138,7 @@ void awsCredentials() throws Exception { testEnvironmentProvider .setEnv("AWS_ACCESS_KEY_ID", awsAccessKeyId) .setEnv("AWS_SECRET_ACCESS_KEY", awsSecretAccessKey) - .setEnv("Token", awsSessionToken) + .setEnv("AWS_SESSION_TOKEN", awsSessionToken) .setEnv("AWS_REGION", "us-east-2"); AwsCredentials awsCredential =