@Immutable public class TokenRequest extends AbstractOptionallyIdentifiedRequest
access token
and an
optional refresh token
at the Token endpoint of the authorisation server. Supports custom request
parameters.
Example token request with an authorisation code grant:
POST /token HTTP/1.1 Host: server.example.com Content-Type: application/x-www-form-URIencoded Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW grant_type=authorization_code &code=SplxlOBeZQQYbYS6WxSbIA &redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb
Related specifications:
Constructor and Description |
---|
TokenRequest(java.net.URI uri,
AuthorizationGrant authzGrant)
Creates a new token request, without client authentication and a
specified client identifier.
|
TokenRequest(java.net.URI uri,
AuthorizationGrant authzGrant,
Scope scope)
Creates a new token request, without client authentication and a
specified client identifier.
|
TokenRequest(java.net.URI uri,
ClientAuthentication clientAuth,
AuthorizationGrant authzGrant)
Creates a new token request with the specified client
authentication.
|
TokenRequest(java.net.URI uri,
ClientAuthentication clientAuth,
AuthorizationGrant authzGrant,
Scope scope)
Creates a new token request with the specified client
authentication.
|
TokenRequest(java.net.URI uri,
ClientAuthentication clientAuth,
AuthorizationGrant authzGrant,
Scope scope,
java.util.Map<java.lang.String,java.lang.String> customParams)
Creates a new token request with the specified client
authentication and additional custom parameters.
|
TokenRequest(java.net.URI uri,
ClientID clientID,
AuthorizationGrant authzGrant)
Creates a new token request, with no explicit client authentication
(may be present in the grant depending on its type).
|
TokenRequest(java.net.URI uri,
ClientID clientID,
AuthorizationGrant authzGrant,
Scope scope)
Creates a new token request, with no explicit client authentication
(may be present in the grant depending on its type).
|
TokenRequest(java.net.URI uri,
ClientID clientID,
AuthorizationGrant authzGrant,
Scope scope,
java.util.Map<java.lang.String,java.lang.String> customParams)
Creates a new token request, with no explicit client authentication
(may be present in the grant depending on its type) and additional
custom parameters.
|
Modifier and Type | Method and Description |
---|---|
AuthorizationGrant |
getAuthorizationGrant()
Gets the authorisation grant.
|
java.lang.String |
getCustomParameter(java.lang.String name)
Returns the specified custom parameter included in the request body.
|
java.util.Map<java.lang.String,java.lang.String> |
getCustomParameters()
Returns the additional custom parameters included in the request
body.
|
Scope |
getScope()
Gets the requested scope.
|
static TokenRequest |
parse(HTTPRequest httpRequest)
Parses a token request from the specified HTTP request.
|
HTTPRequest |
toHTTPRequest()
Returns the matching HTTP request.
|
getClientID
getClientAuthentication
getEndpointURI
public TokenRequest(java.net.URI uri, ClientAuthentication clientAuth, AuthorizationGrant authzGrant, Scope scope)
uri
- The URI of the token endpoint. May be
null
if the toHTTPRequest()
method
will not be used.clientAuth
- The client authentication. Must not be
null
.authzGrant
- The authorisation grant. Must not be null
.scope
- The requested scope, null
if not
specified.public TokenRequest(java.net.URI uri, ClientAuthentication clientAuth, AuthorizationGrant authzGrant, Scope scope, java.util.Map<java.lang.String,java.lang.String> customParams)
uri
- The URI of the token endpoint. May be
null
if the toHTTPRequest()
method will not be used.clientAuth
- The client authentication. Must not be
null
.authzGrant
- The authorisation grant. Must not be
null
.scope
- The requested scope, null
if not
specified.customParams
- Additional custom parameters to be included in
the request body, empty map or null
if
none.public TokenRequest(java.net.URI uri, ClientAuthentication clientAuth, AuthorizationGrant authzGrant)
uri
- The URI of the token endpoint. May be
null
if the toHTTPRequest()
method
will not be used.clientAuth
- The client authentication. Must not be
null
.authzGrant
- The authorisation grant. Must not be null
.public TokenRequest(java.net.URI uri, ClientID clientID, AuthorizationGrant authzGrant, Scope scope)
uri
- The URI of the token endpoint. May be
null
if the toHTTPRequest()
method
will not be used.clientID
- The client identifier, null
if not
specified.authzGrant
- The authorisation grant. Must not be null
.scope
- The requested scope, null
if not
specified.public TokenRequest(java.net.URI uri, ClientID clientID, AuthorizationGrant authzGrant, Scope scope, java.util.Map<java.lang.String,java.lang.String> customParams)
uri
- The URI of the token endpoint. May be
null
if the toHTTPRequest()
method will not be used.clientID
- The client identifier, null
if not
specified.authzGrant
- The authorisation grant. Must not be
null
.scope
- The requested scope, null
if not
specified.customParams
- Additional custom parameters to be included in
the request body, empty map or null
if
none.public TokenRequest(java.net.URI uri, ClientID clientID, AuthorizationGrant authzGrant)
uri
- The URI of the token endpoint. May be
null
if the toHTTPRequest()
method
will not be used.clientID
- The client identifier, null
if not
specified.authzGrant
- The authorisation grant. Must not be null
.public TokenRequest(java.net.URI uri, AuthorizationGrant authzGrant, Scope scope)
uri
- The URI of the token endpoint. May be
null
if the toHTTPRequest()
method
will not be used.authzGrant
- The authorisation grant. Must not be null
.scope
- The requested scope, null
if not
specified.public TokenRequest(java.net.URI uri, AuthorizationGrant authzGrant)
uri
- The URI of the token endpoint. May be
null
if the toHTTPRequest()
method
will not be used.authzGrant
- The authorisation grant. Must not be null
.public AuthorizationGrant getAuthorizationGrant()
public Scope getScope()
null
if not specified.public java.util.Map<java.lang.String,java.lang.String> getCustomParameters()
Example:
resource=http://xxxxxx/PartyOData
public java.lang.String getCustomParameter(java.lang.String name)
name
- The parameter name. Must not be null
.null
if not specified.public HTTPRequest toHTTPRequest()
Request
public static TokenRequest parse(HTTPRequest httpRequest) throws ParseException
httpRequest
- The HTTP request. Must not be null
.ParseException
- If the HTTP request couldn't be parsed to a
token request.Copyright © 2016 Connect2id Ltd.. All Rights Reserved.