Class OAuth2FeignRequestInterceptor
java.lang.Object
org.springframework.cloud.openfeign.security.OAuth2FeignRequestInterceptor
- All Implemented Interfaces:
feign.RequestInterceptor
@Deprecated
public class OAuth2FeignRequestInterceptor
extends Object
implements feign.RequestInterceptor
Deprecated.
Pre-defined custom RequestInterceptor for Feign Requests. It uses the
OAuth2ClientContext
provided from the environment and
construct a new header on the request before it is made by Feign.- Since:
- 3.0.0
- Author:
- Joao Pedro Evangelista, Tim Ysewyn
-
Field Summary
-
Constructor Summary
ConstructorDescriptionOAuth2FeignRequestInterceptor
(org.springframework.security.oauth2.client.OAuth2ClientContext oAuth2ClientContext, org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails resource) Deprecated.Default constructor which uses the provided OAuth2ClientContext and Bearer tokens within Authorization header.OAuth2FeignRequestInterceptor
(org.springframework.security.oauth2.client.OAuth2ClientContext oAuth2ClientContext, org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails resource, String tokenType, String header) Deprecated.Fully customizable constructor for changing token type and header name, in cases of Bearer and Authorization is not the default such as "bearer", "authorization". -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.security.oauth2.common.OAuth2AccessToken
Deprecated.Try to acquire the token using a access token provider.void
apply
(feign.RequestTemplate template) Deprecated.Create a template with the header of provided name and extracted extract.protected String
Deprecated.Extracts the token extract id the access token exists or returning an empty extract if there is no one on the context it may occasionally causes Unauthorized response since the token extract is empty.org.springframework.security.oauth2.common.OAuth2AccessToken
getToken()
Deprecated.Extract the access token within the request or try to acquire a new one by delegating it toacquireAccessToken()
.void
setAccessTokenProvider
(org.springframework.security.oauth2.client.token.AccessTokenProvider accessTokenProvider) Deprecated.
-
Field Details
-
BEARER
Deprecated.The name of the token.- See Also:
-
AUTHORIZATION
Deprecated.The name of the header.- See Also:
-
-
Constructor Details
-
OAuth2FeignRequestInterceptor
public OAuth2FeignRequestInterceptor(org.springframework.security.oauth2.client.OAuth2ClientContext oAuth2ClientContext, org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails resource) Deprecated.Default constructor which uses the provided OAuth2ClientContext and Bearer tokens within Authorization header.- Parameters:
oAuth2ClientContext
- provided contextresource
- type of resource to be accessed
-
OAuth2FeignRequestInterceptor
public OAuth2FeignRequestInterceptor(org.springframework.security.oauth2.client.OAuth2ClientContext oAuth2ClientContext, org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails resource, String tokenType, String header) Deprecated.Fully customizable constructor for changing token type and header name, in cases of Bearer and Authorization is not the default such as "bearer", "authorization".- Parameters:
oAuth2ClientContext
- current oAuth2 Contextresource
- type of resource to be accessedtokenType
- type of token e.g. "token", "Bearer"header
- name of the header e.g. "Authorization", "authorization"
-
-
Method Details
-
apply
public void apply(feign.RequestTemplate template) Deprecated.Create a template with the header of provided name and extracted extract.- Specified by:
apply
in interfacefeign.RequestInterceptor
- See Also:
-
RequestInterceptor.apply(RequestTemplate)
-
extract
Deprecated.Extracts the token extract id the access token exists or returning an empty extract if there is no one on the context it may occasionally causes Unauthorized response since the token extract is empty.- Parameters:
tokenType
- type name of token- Returns:
- token value from context if it exists otherwise empty String
-
getToken
public org.springframework.security.oauth2.common.OAuth2AccessToken getToken()Deprecated.Extract the access token within the request or try to acquire a new one by delegating it toacquireAccessToken()
.- Returns:
- valid token
-
acquireAccessToken
protected org.springframework.security.oauth2.common.OAuth2AccessToken acquireAccessToken() throws org.springframework.security.oauth2.client.resource.UserRedirectRequiredExceptionDeprecated.Try to acquire the token using a access token provider.- Returns:
- valid access token
- Throws:
org.springframework.security.oauth2.client.resource.UserRedirectRequiredException
- in case the user needs to be redirected to an approval page or login page
-
setAccessTokenProvider
public void setAccessTokenProvider(org.springframework.security.oauth2.client.token.AccessTokenProvider accessTokenProvider) Deprecated.
-
OAuth2AccessTokenInterceptor