public final class OAuth2ClientSupport extends Object
client filter feature
that
can supports performing of authenticated OAuth requests.
Authorization flow
For more information about authorization flow, seeOAuth2CodeGrantFlow
.
Client feature
Use method feature(String)
to build the feature. OAuth2 client filter feature registers
the support for performing authenticated requests to the
Service Provider. The feature uses an access token to initialize
the internal filter
which will add Authorization
http header containing OAuth 2 authorization information (based
on bearer
tokens).
The internal filter can be controlled by properties put into
the client request
using ClientRequestContext.setProperty(String, Object)
method. The property key
is defined in this class as a static variables
(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();
Modifier and Type | Field and Description |
---|---|
static String |
OAUTH2_PROPERTY_ACCESS_TOKEN
Key of the property that can be attached to the
client request using
ClientRequestContext.setProperty(String, Object) and that
defines access token that should be used when generating OAuth Authorization
http header. |
Modifier and Type | Method and Description |
---|---|
static OAuth2CodeGrantFlow.Builder |
authorizationCodeGrantFlowBuilder(ClientIdentifier clientIdentifier,
String authorizationUri,
String accessTokenUri)
Get the builder of the
Authorization Code Grant Flow . |
static OAuth2CodeGrantFlow.Builder |
facebookFlowBuilder(ClientIdentifier clientIdentifier,
String redirectURI)
Get a builder that can be directly used to perform Authorization Code Grant flow defined by
Facebook.
|
static javax.ws.rs.core.Feature |
feature(String accessToken)
Build the
client filter feature from the accessToken that will add
Authorization http header to the request with the OAuth authorization information. |
static OAuth2FlowGoogleBuilder |
googleFlowBuilder(ClientIdentifier clientIdentifier,
String redirectURI,
String scope)
Get a builder that can be directly used to perform Authorization Code Grant flow defined by
Google.
|
public static final String OAUTH2_PROPERTY_ACCESS_TOKEN
client request
using
ClientRequestContext.setProperty(String, Object)
and that
defines access token that should be used when generating OAuth Authorization
http header. The property will override the setting of the internal
filter
for the current request only. This property
can be used only when OAauth 2 filter feature
is
registered into the Client
instance.
The value of the property must be a String
.
public static javax.ws.rs.core.Feature feature(String accessToken)
client filter feature
from the accessToken
that will add
Authorization
http header to the request with the OAuth authorization information.accessToken
- Access token to be used in the authorization header or null
if no default access token should be defined. In this case the token
will have to be set for each request using OAUTH2_PROPERTY_ACCESS_TOKEN
property.public static OAuth2CodeGrantFlow.Builder authorizationCodeGrantFlowBuilder(ClientIdentifier clientIdentifier, String authorizationUri, String accessTokenUri)
Authorization Code Grant Flow
.clientIdentifier
- Client identifier (id of application that wants to be approved). Issued by the
Service Provider.authorizationUri
- The URI to which the user should be redirected to authorize our application.
The URI points to the
authorization server and is defined by the Service Provider.accessTokenUri
- The access token URI on which the access token can be requested. The URI points to the
authorization server and is defined by the Service Provider.Authorization Code Grant Flow
.public static OAuth2FlowGoogleBuilder googleFlowBuilder(ClientIdentifier clientIdentifier, String redirectURI, String scope)
clientIdentifier
- Client identifier (id of application that wants to be approved). Issued by the
Service Provider.redirectURI
- URI to which the user (resource owner) should be redirected after he/she
grants access to our application or null
if the application
does not support redirection (eg. is not a web server).scope
- The api to which an access is requested (eg. Google tasks).public static OAuth2CodeGrantFlow.Builder facebookFlowBuilder(ClientIdentifier clientIdentifier, String redirectURI)
clientIdentifier
- Client identifier (id of application that wants to be approved). Issued by the
Service Provider.redirectURI
- URI to which the user (resource owner) should be redirected after he/she
grants access to our application or null
if the application
does not support redirection (eg. is not a web server).
Copyright © 2007-2017, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.