Spring Boot / Spring Cloud / Spring Security: How to correctly obtain an OAuth2 Access Token in a scheduled task -
i have background task (method @scheduled
annotation) calls resource server using ribbon/feign. background task running on authorization server.
the resource server requires calls authenticated (and present set of authorities)
so correct way of obtaining access token calls made scheduled task?
my current solution manually generate access token in custom feign requestinterceptor
, set authorization header each request performed feign.
i tried luck using @enableoauth2client
annotation , hoping build oauth2clientcontext
there inject feign interceptor (or have work entirely taken care of oauth2feignrequestinterceptor
spring-cloud-security jar) i've gathered looking @ tutorial clientcontext built 1 has register web filter in security chain. won't work situation there isn't web request being processed call using feign originates scheduled task..
unfortunately topic not covered of (otherwise commendable) spring docs / examples - far have seen - hoping find answer here on =)
regards
Comments
Post a Comment