Class OAuth2AccessTokenInterceptor
java.lang.Object
org.springframework.cloud.openfeign.security.OAuth2AccessTokenInterceptor
- All Implemented Interfaces:
feign.RequestInterceptor
A
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.- Since:
- 4.0.0
- Author:
- Dangzhicairang(小水牛), Olga Maciaszek-Sharma
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOAuth2AccessTokenInterceptor(String tokenType, String header, String clientRegistrationId, org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) OAuth2AccessTokenInterceptor(String clientRegistrationId, org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) OAuth2AccessTokenInterceptor(org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) -
Method Summary
-
Field Details
-
BEARER
The name of the token.- See Also:
-
AUTHORIZATION
The name of the header.- See Also:
-
-
Constructor Details
-
OAuth2AccessTokenInterceptor
public OAuth2AccessTokenInterceptor(org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) -
OAuth2AccessTokenInterceptor
public OAuth2AccessTokenInterceptor(String clientRegistrationId, org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager oAuth2AuthorizedClientManager) -
OAuth2AccessTokenInterceptor
-
-
Method Details
-
apply
public void apply(feign.RequestTemplate template) - Specified by:
applyin interfacefeign.RequestInterceptor
-
getToken
public org.springframework.security.oauth2.core.OAuth2AccessToken getToken(feign.RequestTemplate template) -
getToken
protected org.springframework.security.oauth2.core.OAuth2AccessToken getToken(String clientRegistrationId)
-