Skip to content

Commit cb09aef

Browse files
committed
Use OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE
Issue gh-83
1 parent ebcdf79 commit cb09aef

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2TokenRevocationAuthenticationProvider.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
7474
} else if (TokenType.ACCESS_TOKEN.getValue().equals(tokenTypeHint)) {
7575
tokenType = TokenType.ACCESS_TOKEN;
7676
} else {
77-
// TODO Add OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE
78-
throw new OAuth2AuthenticationException(new OAuth2Error("unsupported_token_type"));
77+
throw new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE));
7978
}
8079
}
8180

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2TokenRevocationAuthenticationProviderTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ public void authenticateWhenInvalidTokenTypeThenThrowOAuth2AuthenticationExcepti
100100
RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
101101
OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(registeredClient);
102102
OAuth2TokenRevocationAuthenticationToken authentication = new OAuth2TokenRevocationAuthenticationToken(
103-
"token", clientPrincipal, "unsupported_token_type");
103+
"token", clientPrincipal, OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE);
104104
assertThatThrownBy(() -> this.authenticationProvider.authenticate(authentication))
105105
.isInstanceOf(OAuth2AuthenticationException.class)
106106
.extracting(ex -> ((OAuth2AuthenticationException) ex).getError())
107107
.extracting("errorCode")
108-
.isEqualTo("unsupported_token_type");
108+
.isEqualTo(OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE);
109109
}
110110

111111
@Test

0 commit comments

Comments
 (0)