Skip to content

Commit

Permalink
fix: change revoke request from get to post (#979)
Browse files Browse the repository at this point in the history
  • Loading branch information
sai-sunder-s committed Aug 17, 2022
1 parent f06b4ce commit ead58b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions oauth2_http/java/com/google/auth/oauth2/UserAuthorizer.java
Expand Up @@ -315,10 +315,14 @@ public void revokeAuthorization(String userId) throws IOException {
OAuth2Utils.validateOptionalString(tokenJson, "refresh_token", TOKEN_STORE_ERROR);
// If both tokens are present, either can be used
String revokeToken = (refreshToken != null) ? refreshToken : accessTokenValue;

GenericUrl revokeUrl = new GenericUrl(OAuth2Utils.TOKEN_REVOKE_URI);
revokeUrl.put("token", revokeToken);
GenericData genericData = new GenericData();
genericData.put("token", revokeToken);
UrlEncodedContent content = new UrlEncodedContent(genericData);

HttpRequestFactory requestFactory = transportFactory.create().createRequestFactory();
HttpRequest tokenRequest = requestFactory.buildGetRequest(revokeUrl);
HttpRequest tokenRequest = requestFactory.buildPostRequest(revokeUrl, content);
tokenRequest.execute();

if (deleteTokenException != null) {
Expand Down
Expand Up @@ -257,7 +257,7 @@ public LowLevelHttpResponse execute() throws IOException {
return new MockLowLevelHttpRequest(url) {
@Override
public LowLevelHttpResponse execute() throws IOException {
Map<String, String> parameters = TestUtils.parseQuery(query);
Map<String, String> parameters = TestUtils.parseQuery(this.getContentAsString());
String token = parameters.get("token");
if (token == null) {
throw new IOException("Token to revoke not found.");
Expand Down

0 comments on commit ead58b2

Please sign in to comment.