diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginAuthenticationProvider.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginAuthenticationProvider.java index 22b2590bdf..fb569f1327 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginAuthenticationProvider.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginAuthenticationProvider.java @@ -115,9 +115,7 @@ public class OAuth2LoginAuthenticationProvider implements AuthenticationProvider authorizationCodeAuthentication.getClientRegistration(), authorizationCodeAuthentication.getAuthorizationExchange())); - OAuth2AccessToken accessToken = new OAuth2AccessToken(accessTokenResponse.getTokenType(), - accessTokenResponse.getTokenValue(), accessTokenResponse.getIssuedAt(), - accessTokenResponse.getExpiresAt(), accessTokenResponse.getScopes()); + OAuth2AccessToken accessToken = accessTokenResponse.getAccessToken(); OAuth2User oauth2User = this.userService.loadUser( new OAuth2UserRequest(authorizationCodeAuthentication.getClientRegistration(), accessToken)); diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcAuthorizationCodeAuthenticationProvider.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcAuthorizationCodeAuthenticationProvider.java index dc3a80cd9c..119a45fca0 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcAuthorizationCodeAuthenticationProvider.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcAuthorizationCodeAuthenticationProvider.java @@ -133,9 +133,7 @@ public class OidcAuthorizationCodeAuthenticationProvider implements Authenticati authorizationCodeAuthentication.getClientRegistration(), authorizationCodeAuthentication.getAuthorizationExchange())); - OAuth2AccessToken accessToken = new OAuth2AccessToken(accessTokenResponse.getTokenType(), - accessTokenResponse.getTokenValue(), accessTokenResponse.getIssuedAt(), - accessTokenResponse.getExpiresAt(), accessTokenResponse.getScopes()); + OAuth2AccessToken accessToken = accessTokenResponse.getAccessToken(); ClientRegistration clientRegistration = authorizationCodeAuthentication.getClientRegistration(); diff --git a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/OAuth2AccessTokenResponse.java b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/OAuth2AccessTokenResponse.java index db9f6b030a..029e829a55 100644 --- a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/OAuth2AccessTokenResponse.java +++ b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/OAuth2AccessTokenResponse.java @@ -39,24 +39,8 @@ public final class OAuth2AccessTokenResponse { private OAuth2AccessTokenResponse() { } - public String getTokenValue() { - return this.accessToken.getTokenValue(); - } - - public OAuth2AccessToken.TokenType getTokenType() { - return this.accessToken.getTokenType(); - } - - public Instant getIssuedAt() { - return this.accessToken.getIssuedAt(); - } - - public Instant getExpiresAt() { - return this.accessToken.getExpiresAt(); - } - - public Set getScopes() { - return this.accessToken.getScopes(); + public OAuth2AccessToken getAccessToken() { + return this.accessToken; } public Map getAdditionalParameters() {