https://github.com/spring-projects/spring-security/blob/main/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/AuthorizationCodeOAuth2AuthorizedClientProvider.java

The code in the link above returns either only a null or an exception. While the documentation says it also returns an Oauth2AuthorizedClient

Comment From: jzheaux

Thanks for the report, @talentedasian. Would you be able to submit a PR updating the description?

I imagine it might read something like this:

/**
  * ...
  * @return {@code null} if authorization is not supported
  * @throws ClientAuthorizationRequiredException in order to trigger authorization
  */

Comment From: talentedasian

Was it intentional to just either return null or throw an exception? If so, do you mind explaining why as I think that it if it does really return just a null then it would be redundant

Comment From: talentedasian

Thanks for the report, @talentedasian. Would you be able to submit a PR updating the description?

I imagine it might read something like this:

java /** * ... * @return {@code null} if authorization is not supported * @throws ClientAuthorizationRequiredException in order to trigger authorization */

I think it's best if someone else updates the description :)

Comment From: talentedasian

Was it intentional to just either return null or throw an exception? If so, do you mind explaining why as I think that it if it does really return just a null then it would be redundant

After reading through the code again, I now get it. The name was confusing though. But yeah, changing the description should suffice