最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

spring cloud feign - OAuth2AccessTokenInterceptor Error while trigger the API via CRON Job - Stack Overflow

programmeradmin3浏览0评论

I used below code to set the authorization when my service connects to some other service via feign Client.

  @Bean
    public RequestInterceptor requestInterceptor() {
        return new OAuth2AccessTokenInterceptor(APP_INNER_ACCESS_CREDENTIAL, oAuth2AuthorizedClientManager);}

It works fine and generates and sends the token when we hit the API from bowser/swagger etc. But when I trigger the API as a cron job as it is not a HTTPRequest, this call fails with below ERROR

ERROR DETAILS

java.lang.IllegalArgumentException: servletRequest cannot be null at .springframework.util.Assert.notNull(Assert.java:172) ~[spring-core-6.1.4.jar:6.1.4] at .springframework.security.oauth2.client.web.DefaultOAuth2AuthorizedClientManager.authorize(DefaultOAuth2AuthorizedClientManager.java:144)

Any alternate way to solve this?

发布评论

评论列表(0)

  1. 暂无评论