diff --git a/oauth2_http/java/com/google/auth/oauth2/UserAuthorizer.java b/oauth2_http/java/com/google/auth/oauth2/UserAuthorizer.java index 6fd54c2e6..63cc23170 100644 --- a/oauth2_http/java/com/google/auth/oauth2/UserAuthorizer.java +++ b/oauth2_http/java/com/google/auth/oauth2/UserAuthorizer.java @@ -265,8 +265,6 @@ public UserCredentials getCredentials(String userId) throws IOException { * * @param code Code returned from OAuth2 consent prompt. * @param baseUri The URI to resolve the OAuth2 callback URI relative to. - * @param additionalParameters Additional parameters to be added to the post body of token - * endpoint request. * @return the UserCredentials instance created from the authorization code. * @throws IOException An error from the server API call to get the tokens. */ diff --git a/oauth2_http/javatests/com/google/auth/oauth2/MockTokenServerTransport.java b/oauth2_http/javatests/com/google/auth/oauth2/MockTokenServerTransport.java index 219510c1a..95680c02e 100644 --- a/oauth2_http/javatests/com/google/auth/oauth2/MockTokenServerTransport.java +++ b/oauth2_http/javatests/com/google/auth/oauth2/MockTokenServerTransport.java @@ -65,7 +65,7 @@ public class MockTokenServerTransport extends MockHttpTransport { final Map serviceAccounts = new HashMap(); final Map gdchServiceAccounts = new HashMap(); final Map codes = new HashMap(); - final Map> customParameters = + final Map> additionalParameters = new HashMap>(); URI tokenServerUri = OAuth2Utils.TOKEN_SERVER_URI; private IOException error; @@ -87,13 +87,13 @@ public void addAuthorizationCode( String refreshToken, String accessToken, String grantedScopes, - Map customParameters) { + Map additionalParameters) { codes.put(code, refreshToken); refreshTokens.put(refreshToken, accessToken); this.grantedScopes.put(refreshToken, grantedScopes); - if (customParameters != null) { - this.customParameters.put(refreshToken, customParameters); + if (additionalParameters != null) { + this.additionalParameters.put(refreshToken, additionalParameters); } } @@ -231,16 +231,24 @@ public LowLevelHttpResponse execute() throws IOException { grantedScopesString = grantedScopes.get(refreshToken); } - if (customParameters.containsKey(refreshToken)) { - Map customParametersMap = customParameters.get(refreshToken); - for (Map.Entry entry : customParametersMap.entrySet()) { + if (additionalParameters.containsKey(refreshToken)) { + Map additionalParametersMap = additionalParameters.get(refreshToken); + for (Map.Entry entry : additionalParametersMap.entrySet()) { String key = entry.getKey(); - String value = entry.getValue(); + String expectedValue = entry.getValue(); if (!query.containsKey(key)) { - throw new IllegalArgumentException("Missing custom parameter: " + key); - } else if (!query.get(key).equals(value)) { - throw new IllegalArgumentException( - "Custom parameter " + key + " does not match: " + value); + throw new IllegalArgumentException("Missing additional parameter: " + key); + } else { + String actualValue = query.get(key); + if (!expectedValue.equals(actualValue)) { + throw new IllegalArgumentException( + "For additional parameter " + + key + + ", Actual value: " + + actualValue + + ", Expected value: " + + expectedValue); + } } } }