Browse Source

Use OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE

Issue gh-83
Joe Grandja 5 years ago
parent
commit
cb09aef605

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

@@ -74,8 +74,7 @@ public class OAuth2TokenRevocationAuthenticationProvider implements Authenticati
 			} else if (TokenType.ACCESS_TOKEN.getValue().equals(tokenTypeHint)) {
 				tokenType = TokenType.ACCESS_TOKEN;
 			} else {
-				// TODO Add OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE
-				throw new OAuth2AuthenticationException(new OAuth2Error("unsupported_token_type"));
+				throw new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE));
 			}
 		}
 

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

@@ -100,12 +100,12 @@ public class OAuth2TokenRevocationAuthenticationProviderTests {
 		RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
 		OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(registeredClient);
 		OAuth2TokenRevocationAuthenticationToken authentication = new OAuth2TokenRevocationAuthenticationToken(
-				"token", clientPrincipal, "unsupported_token_type");
+				"token", clientPrincipal, OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE);
 		assertThatThrownBy(() -> this.authenticationProvider.authenticate(authentication))
 				.isInstanceOf(OAuth2AuthenticationException.class)
 				.extracting(ex -> ((OAuth2AuthenticationException) ex).getError())
 				.extracting("errorCode")
-				.isEqualTo("unsupported_token_type");
+				.isEqualTo(OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE);
 	}
 
 	@Test