I have a Spring Boot Resource Server protected with OAuth2 (KeyCloak). I can access endpoints with Bearer Token. Now, I want to call another service protected by the Auth Server. I would like to relay the token. I could not find a clear guide as to how to do it.
My dependency is:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
My application.yml is like:
spring:
security:
oauth2:
resourceserver:
jwt:
issuer-uri: <info>
I am trying to create OAuth2RestTemplate like:
@Bean
public OAuth2RestTemplate oauth2RestTemplate(OAuth2ClientContext oauth2ClientContext, OAuth2ProtectedResourceDetails details) {
return new OAuth2RestTemplate(details, oauth2ClientContext);
}
But I am getting error:
required a bean of type 'org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails' that could not be found.
How can I fix this?