public class OAuth2AccessTokenInterceptor extends Object implements feign.RequestInterceptor
RequestInterceptor for OAuth2 Feign Requests. By default, it uses the
OAuth2AuthorizedClientManager to get OAuth2AuthorizedClient that
holds an OAuth2AccessToken. If the user has specified an OAuth2
clientRegistrationId using the feign.oauth2.clientRegistrationId
property, it will be used to retrieve the token. If the token is not retrieved or the
clientRegistrationId has not been specified, the serviceId retrieved
from the url host segment will be used. This approach is convenient for
load-balanced Feign clients. For non-load-balanced ones, the property-based
clientRegistrationId is a suitable approach.| Modifier and Type | Field and Description |
|---|---|
static String |
AUTHORIZATION
The name of the header.
|
static String |
BEARER
The name of the token.
|
| Constructor and Description |
|---|
OAuth2AccessTokenInterceptor(org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) |
OAuth2AccessTokenInterceptor(String clientRegistrationId,
org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) |
OAuth2AccessTokenInterceptor(String tokenType,
String header,
String clientRegistrationId,
org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) |
| Modifier and Type | Method and Description |
|---|---|
void |
apply(feign.RequestTemplate template) |
org.springframework.security.oauth2.core.OAuth2AccessToken |
getToken(feign.RequestTemplate template) |
protected org.springframework.security.oauth2.core.OAuth2AccessToken |
getToken(String clientRegistrationId) |
public static final String BEARER
public static final String AUTHORIZATION
public OAuth2AccessTokenInterceptor(org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager)
public OAuth2AccessTokenInterceptor(String clientRegistrationId, org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager)
public void apply(feign.RequestTemplate template)
apply in interface feign.RequestInterceptorpublic org.springframework.security.oauth2.core.OAuth2AccessToken getToken(feign.RequestTemplate template)
protected org.springframework.security.oauth2.core.OAuth2AccessToken getToken(String clientRegistrationId)
Copyright © 2023 Pivotal Software, Inc.. All rights reserved.