com.nimbusds.oauth2.sdk
Class AccessTokenRequest

java.lang.Object
  extended by com.nimbusds.oauth2.sdk.TokenRequest
      extended by com.nimbusds.oauth2.sdk.AccessTokenRequest
All Implemented Interfaces:
Message, Request

@Immutable
public final class AccessTokenRequest
extends TokenRequest

Access token request to the Token endpoint. Used to obtain an access token and an optional refresh token from the authorisation server. This class is immutable.

Supported authorisation grant types:

Example HTTP request, with client secret basic authentication:

 POST /token HTTP/1.1
 Host: server.example.com
 Content-Type: application/x-www-form-urlencoded
 Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
 
 grant_type=authorization_code
 &code=SplxlOBeZQQYbYS6WxSbIA
 &redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb
 

Related specifications:

Author:
Vladimir Dzhuvinov

Constructor Summary
AccessTokenRequest(AuthorizationCode code, URL redirectURI, ClientAuthentication clientAuth)
          Creates a new authenticated access token request, using an authorisation code grant.
AccessTokenRequest(AuthorizationCode code, URL redirectURI, ClientID clientID)
          Creates a new unauthenticated access token request, using an authorisation code grant.
AccessTokenRequest(Scope scope, ClientAuthentication clientAuth)
          Creates a new authenticated access token request, using a client credentials grant.
AccessTokenRequest(String username, String password, Scope scope)
          Creates a new authenticated access token request, using a resource owner password credentials grant.
 
Method Summary
 AuthorizationCode getAuthorizationCode()
          Gets the authorisation code.
 ClientID getClientID()
          Gets the client identifier.
 String getPassword()
          Gets the resource owner password.
 URL getRedirectURI()
          Gets the redirect URI.
 Scope getScope()
          Gets the access scope.
 String getUsername()
          Gets the resource owner username.
static AccessTokenRequest parse(HTTPRequest httpRequest)
          Parses the specified HTTP request for an access token request.
 HTTPRequest toHTTPRequest(URL url)
          Returns the matching HTTP request.
 
Methods inherited from class com.nimbusds.oauth2.sdk.TokenRequest
getClientAuthentication, getGrantType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccessTokenRequest

public AccessTokenRequest(AuthorizationCode code,
                          URL redirectURI,
                          ClientID clientID)
Creates a new unauthenticated access token request, using an authorisation code grant.

Parameters:
code - The authorisation code received from the authorisation server. Must not be null.
redirectURI - The redirect URI, may be null if specified in the initial authorisation request.
clientID - The client identifier. Must not be null.

AccessTokenRequest

public AccessTokenRequest(AuthorizationCode code,
                          URL redirectURI,
                          ClientAuthentication clientAuth)
Creates a new authenticated access token request, using an authorisation code grant.

Parameters:
code - The authorisation code received from the authorisation server. Must not be null.
redirectURI - The redirect URI, may be null if not specified in the initial authorisation request.
clientAuth - The client authentication. Must not be null.

AccessTokenRequest

public AccessTokenRequest(String username,
                          String password,
                          Scope scope)
Creates a new authenticated access token request, using a resource owner password credentials grant.

Parameters:
username - The resource owner username. Must not be null.
password - The resource owner password. Must not be null.
scope - The scope of the access request, null if not specified.

AccessTokenRequest

public AccessTokenRequest(Scope scope,
                          ClientAuthentication clientAuth)
Creates a new authenticated access token request, using a client credentials grant.

Parameters:
scope - The scope of the access request, null if not specified.
clientAuth - The client authentication. Must not be null.
Method Detail

getAuthorizationCode

public AuthorizationCode getAuthorizationCode()
Gets the authorisation code. Applies to requests using an authorisation code grant.

Returns:
The authorisation code, null if not specified.

getRedirectURI

public URL getRedirectURI()
Gets the redirect URI. Applies to requests using an authorisation code grant

Returns:
The redirect URI, null if not specified.

getClientID

public ClientID getClientID()
Gets the client identifier. Applies to requests using an authorisation code grant.

Returns:
The client identifier, null if not specified.

getUsername

public String getUsername()
Gets the resource owner username. Applies to requests using a resource owner password credentials grant.

Returns:
The resource owner username, null if not specified.

getPassword

public String getPassword()
Gets the resource owner password. Applies to requests using a resource owner password credentials grant.

Returns:
The resource owner password, null if not specified.

getScope

public Scope getScope()
Gets the access scope. Applies to requests using a resource owner password credentials or client credentials grant.

Returns:
The access scope, null if not specified.

toHTTPRequest

public HTTPRequest toHTTPRequest(URL url)
                          throws SerializeException
Description copied from interface: Request
Returns the matching HTTP request.

Parameters:
url - The URL of the HTTP endpoint for which the request is intended. Must not be null.
Returns:
The HTTP request.
Throws:
SerializeException - If the request message couldn't be serialised to an HTTP request.

parse

public static AccessTokenRequest parse(HTTPRequest httpRequest)
                                throws ParseException
Parses the specified HTTP request for an access token request.

Parameters:
httpRequest - The HTTP request. Must not be null.
Returns:
The access token request.
Throws:
ParseException - If the HTTP request couldn't be parsed to an access token request.


Copyright © 2013 NimbusDS. All Rights Reserved.