Skip to content

Commit ead58b2

Browse files
authored
fix: change revoke request from get to post (#979)
1 parent f06b4ce commit ead58b2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,14 @@ public void revokeAuthorization(String userId) throws IOException {
315315
OAuth2Utils.validateOptionalString(tokenJson, "refresh_token", TOKEN_STORE_ERROR);
316316
// If both tokens are present, either can be used
317317
String revokeToken = (refreshToken != null) ? refreshToken : accessTokenValue;
318+
318319
GenericUrl revokeUrl = new GenericUrl(OAuth2Utils.TOKEN_REVOKE_URI);
319-
revokeUrl.put("token", revokeToken);
320+
GenericData genericData = new GenericData();
321+
genericData.put("token", revokeToken);
322+
UrlEncodedContent content = new UrlEncodedContent(genericData);
323+
320324
HttpRequestFactory requestFactory = transportFactory.create().createRequestFactory();
321-
HttpRequest tokenRequest = requestFactory.buildGetRequest(revokeUrl);
325+
HttpRequest tokenRequest = requestFactory.buildPostRequest(revokeUrl, content);
322326
tokenRequest.execute();
323327

324328
if (deleteTokenException != null) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public LowLevelHttpResponse execute() throws IOException {
257257
return new MockLowLevelHttpRequest(url) {
258258
@Override
259259
public LowLevelHttpResponse execute() throws IOException {
260-
Map<String, String> parameters = TestUtils.parseQuery(query);
260+
Map<String, String> parameters = TestUtils.parseQuery(this.getContentAsString());
261261
String token = parameters.get("token");
262262
if (token == null) {
263263
throw new IOException("Token to revoke not found.");

0 commit comments

Comments
 (0)