Hi,
I am using CRISP on 11.x(Hippo CMS),
1.How to configure OAuth2RestTemplate if AcessToken is already Available and avoid calling for AcessToken
at bootstrap/configuration/src/main/resources/configuration/modules/crispregistry/moduleconfig/resourceresolvercontainer.
2. Can I programmatically .set the AcessToken from the component if so How…?
Many Thanks
Srinivas Jasti
Your question is really spring-security-oauth2 specific, not Hippo CMS specific.
As CRISP API and configuration simply assembles spring and spring-security and spring-security-oauth2 beans in XML, you should figure out whether it’s possible in those libraries and how.
Anyway, OAuth2RestTemplate
has another constructor you can possibly try with:
public OAuth2RestTemplate(OAuth2ProtectedResourceDetails resource, OAuth2ClientContext context) {
// ...
}
Unless you specify it, context
is a DefaultOAuth2ClientContext
by default.
OAuth2RestTemplate
invokes its own #getAccessToken()
which calls on context.getAccessToken()
.
Therefore, it seems technically possible to pass a new DefaultOAuth2ClientContext(OAuth2AccessToken)
–where you pass an OAuth2AccessToken
somehow–instance when creating a DefaultOAuth2ClientContext
for your OAuth2RestTemplate
bean configuration.
Woonsan