Skip to content

Commit c8c3073

Browse files
authored
fix: environment variable is "AWS_SESSION_TOKEN" and not "Token" (googleapis#772)
1 parent 3971244 commit c8c3073

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

oauth2_http/java/com/google/auth/oauth2/AwsCredentials.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ AwsSecurityCredentials getAwsSecurityCredentials() throws IOException {
273273
// Check environment variables for credentials first.
274274
String accessKeyId = getEnvironmentProvider().getEnv("AWS_ACCESS_KEY_ID");
275275
String secretAccessKey = getEnvironmentProvider().getEnv("AWS_SECRET_ACCESS_KEY");
276-
String token = getEnvironmentProvider().getEnv("Token");
276+
String token = getEnvironmentProvider().getEnv("AWS_SESSION_TOKEN");
277277
if (accessKeyId != null && secretAccessKey != null) {
278278
return new AwsSecurityCredentials(accessKeyId, secretAccessKey, token);
279279
}

oauth2_http/javatests/com/google/auth/oauth2/AwsCredentialsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ void getAwsSecurityCredentials_fromEnvironmentVariablesWithToken() throws IOExce
276276
environmentProvider
277277
.setEnv("AWS_ACCESS_KEY_ID", "awsAccessKeyId")
278278
.setEnv("AWS_SECRET_ACCESS_KEY", "awsSecretAccessKey")
279-
.setEnv("Token", "token");
279+
.setEnv("AWS_SESSION_TOKEN", "awsSessionToken");
280280

281281
AwsCredentials testAwsCredentials =
282282
(AwsCredentials)
@@ -288,7 +288,7 @@ void getAwsSecurityCredentials_fromEnvironmentVariablesWithToken() throws IOExce
288288

289289
assertEquals("awsAccessKeyId", credentials.getAccessKeyId());
290290
assertEquals("awsSecretAccessKey", credentials.getSecretAccessKey());
291-
assertEquals("token", credentials.getToken());
291+
assertEquals("awsSessionToken", credentials.getToken());
292292
}
293293

294294
@Test

oauth2_http/javatests/com/google/auth/oauth2/AwsRequestSignerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,9 @@ public AwsSecurityCredentials retrieveAwsSecurityCredentials() throws IOExceptio
535535

536536
GenericJson json = parser.parseAndClose(stream, StandardCharsets.UTF_8, GenericJson.class);
537537

538-
String awsToken = (String) json.get("Token");
539-
String secretAccessKey = (String) json.get("SecretAccessKey");
540538
String accessKeyId = (String) json.get("AccessKeyId");
539+
String secretAccessKey = (String) json.get("SecretAccessKey");
540+
String awsToken = (String) json.get("Token");
541541

542542
return new AwsSecurityCredentials(accessKeyId, secretAccessKey, awsToken);
543543
}

oauth2_http/javatests/com/google/auth/oauth2/ITWorkloadIdentityFederationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void awsCredentials() throws Exception {
138138
testEnvironmentProvider
139139
.setEnv("AWS_ACCESS_KEY_ID", awsAccessKeyId)
140140
.setEnv("AWS_SECRET_ACCESS_KEY", awsSecretAccessKey)
141-
.setEnv("Token", awsSessionToken)
141+
.setEnv("AWS_SESSION_TOKEN", awsSessionToken)
142142
.setEnv("AWS_REGION", "us-east-2");
143143

144144
AwsCredentials awsCredential =

0 commit comments

Comments
 (0)