Class OAuth2ClientFeature
- java.lang.Object
-
- org.glassfish.jersey.client.oauth2.OAuth2ClientFeature
-
- All Implemented Interfaces:
javax.ws.rs.core.Feature
class OAuth2ClientFeature extends java.lang.Object implements javax.ws.rs.core.Feature
OAuth2 client filter feature registers the support for performing authenticated requests to the Service Provider. The feature does not perform Authorization Flow (seeOAuth2CodeGrantFlow
for details how to use Authorization Flow and retrieve Access Token). The feature uses access to initialize the internalfilter
which will addAuthorization
http header containing OAuth 2 authorization information including (based onbearer
tokens).The internal filter can be controlled by properties put into the
Example of using specific access token for one request:client request
usingClientRequestContext.setProperty(String, Object)
method. The property key is defined in this class as a static variables (OAuth2ClientSupport.OAUTH2_PROPERTY_ACCESS_TOKEN
(see its javadoc for usage). Using the property a specific access token can be defined for each request.final Response response = client.target("foo").request() .property(OAUTH2_PROPERTY_ACCESS_TOKEN, "6ab45ab465e46f54d771a").get();
- Since:
- 2.3
-
-
Field Summary
Fields Modifier and Type Field Description private OAuth2ClientFilter
filter
-
Constructor Summary
Constructors Constructor Description OAuth2ClientFeature()
Create a new filter feature with no default access token.OAuth2ClientFeature(java.lang.String accessToken)
Create a new feature initialized for the access token.OAuth2ClientFeature(OAuth2ClientFilter filter)
Create a new feature with the givenfilter
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
configure(javax.ws.rs.core.FeatureContext context)
-
-
-
Field Detail
-
filter
private final OAuth2ClientFilter filter
-
-
Constructor Detail
-
OAuth2ClientFeature
public OAuth2ClientFeature(java.lang.String accessToken)
Create a new feature initialized for the access token.- Parameters:
accessToken
- Access token.
-
OAuth2ClientFeature
public OAuth2ClientFeature()
Create a new filter feature with no default access token. The token will have to be specified byOAuth2ClientSupport.OAUTH2_PROPERTY_ACCESS_TOKEN
for each request otherwise noAuthorization
http header will be added.
-
OAuth2ClientFeature
OAuth2ClientFeature(OAuth2ClientFilter filter)
Create a new feature with the givenfilter
.- Parameters:
filter
- Filter instance.
-
-