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 a82d320e53..5aea261f9d 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 @@ -110,7 +110,7 @@ public class OAuth2LoginAuthenticationProvider implements AuthenticationProvider } catch (OAuth2AuthorizationException ex) { OAuth2Error oauth2Error = ex.getError(); - throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString()); + throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString(), ex); } OAuth2AccessToken accessToken = authorizationCodeAuthenticationToken.getAccessToken(); Map additionalParameters = authorizationCodeAuthenticationToken.getAdditionalParameters(); diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginReactiveAuthenticationManager.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginReactiveAuthenticationManager.java index e4b72951b5..fc91427d5a 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginReactiveAuthenticationManager.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/authentication/OAuth2LoginReactiveAuthenticationManager.java @@ -99,7 +99,7 @@ public class OAuth2LoginReactiveAuthenticationManager implements ReactiveAuthent } return this.authorizationCodeManager.authenticate(token) .onErrorMap(OAuth2AuthorizationException.class, - (e) -> new OAuth2AuthenticationException(e.getError(), e.getError().toString())) + (e) -> new OAuth2AuthenticationException(e.getError(), e.getError().toString(), e)) .cast(OAuth2AuthorizationCodeAuthenticationToken.class).flatMap(this::onSuccess); }); } 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 9c956fcfcc..6c246d31c0 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 @@ -173,7 +173,7 @@ public class OidcAuthorizationCodeAuthenticationProvider implements Authenticati } catch (OAuth2AuthorizationException ex) { OAuth2Error oauth2Error = ex.getError(); - throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString()); + throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString(), ex); } } diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcAuthorizationCodeReactiveAuthenticationManager.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcAuthorizationCodeReactiveAuthenticationManager.java index 4d536afb5a..6dd88bd612 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcAuthorizationCodeReactiveAuthenticationManager.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/oidc/authentication/OidcAuthorizationCodeReactiveAuthenticationManager.java @@ -142,7 +142,7 @@ public class OidcAuthorizationCodeReactiveAuthenticationManager implements React return this.accessTokenResponseClient.getTokenResponse(authzRequest).flatMap( (accessTokenResponse) -> authenticationResult(authorizationCodeAuthentication, accessTokenResponse)) .onErrorMap(OAuth2AuthorizationException.class, - (e) -> new OAuth2AuthenticationException(e.getError(), e.getError().toString())) + (e) -> new OAuth2AuthenticationException(e.getError(), e.getError().toString(), e)) .onErrorMap(JwtException.class, (e) -> { OAuth2Error invalidIdTokenError = new OAuth2Error(INVALID_ID_TOKEN_ERROR_CODE, e.getMessage(), null);