OAuth2AuthorizedClientManager失败时自动重试获取令牌

时间:2020-09-22 21:10:32

标签: spring-security oauth-2.0 spring-webflux

我们的Oauth提供程序偶尔出现打ic,这导致我们看到以下异常。 WebClientResponseException$InternalServerError: 500 Cannot get token, expected 2xx HTTP Status code

是否可以将我们的authorizationManger配置为自动重试5xx错误?

// webclient configuration
@Bean
fun webClient(): WebClient {
    val oauth = ServerOAuth2AuthorizedClientExchangeFilterFunction(authorizedClientManager)
    oauth.setDefaultClientRegistrationId("charges")

    return WebClient.builder()
        .filter(oauth)
        .build()
}

// AuthorizedClientManager configuration
@Bean
fun createAuthorizedClientManager() =
    AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager(
        reactiveClientRegistrationRepository,
        reactiveOAuth2AuthorizedClientService
    )

0 个答案:

没有答案