public class AccessTokenServerResource extends OAuthServerResource
{ @code public Restlet createInboundRoot(){ ... root.attach("/token", AccessTokenServerResource.class); ... } }
clients, PARAMETER_DEFAULT_SCOPE, tokens
ACCESS_TOKEN, CLIENT_ID, CLIENT_SECRET, CODE, ERROR, ERROR_DESC, ERROR_URI, EXPIRES_IN, GRANT_TYPE, PASSWORD, REDIR_URI, REFRESH_TOKEN, RESPONSE_TYPE, SCOPE, STATE, TOKEN_TYPE, TOKEN_TYPE_BEARER, TOKEN_TYPE_MAC, USERNAME
Constructor and Description |
---|
AccessTokenServerResource() |
Modifier and Type | Method and Description |
---|---|
protected void |
doCatch(Throwable t)
Handle errors as described in 5.2 Error Response.
|
protected void |
ensureGrantTypeAllowed(org.restlet.ext.oauth.internal.Client client,
GrantType grantType) |
protected org.restlet.ext.oauth.internal.Client |
getAuthenticatedClient() |
protected org.restlet.ext.oauth.internal.Client |
getClient(Form params)
Get request parameter "client_id".
|
protected String |
getCode(Form params)
Get request parameter "code".
|
protected GrantType |
getGrantType(Form params)
Get request parameter "grant_type".
|
protected String |
getPassword(Form params)
Get request parameter "password".
|
protected String |
getRedirectURI(Form params)
Get request parameter "redirect_uri".
|
protected String |
getRefreshToken(Form params)
Get request parameter "refresh_token".
|
protected String |
getUsername(Form params)
Get request parameter "username".
|
Representation |
requestToken(Representation input)
Handles the
Post request. |
protected Representation |
responseTokenRepresentation(org.restlet.ext.oauth.internal.Token token,
String[] requestedScope)
Response JSON document with valid token.
|
addCacheDirective, doInit, getScope, getState, responseErrorRepresentation
abort, commit, delete, delete, describeVariants, doConditionalHandle, doError, doHandle, doHandle, doNegotiatedHandle, get, get, getAttribute, getDescription, getInfo, getInfo, getName, getOnSent, getPreferredVariant, getRole, getVariants, getVariants, handle, hasAnnotations, head, head, isAnnotated, isAutoCommitting, isCommitted, isConditional, isExisting, isInRole, isNegotiated, options, options, patch, patch, post, post, put, put, redirectPermanent, redirectPermanent, redirectSeeOther, redirectSeeOther, redirectTemporary, redirectTemporary, setAllowedMethods, setAnnotated, setAttribute, setAutoCommitting, setChallengeRequests, setCommitted, setConditional, setCookieSettings, setDescription, setDimensions, setExisting, setLocationRef, setLocationRef, setName, setNegotiated, setOnSent, setProxyChallengeRequests, setServerInfo, setStatus, setStatus, setStatus, setStatus, updateAllowedMethods, updateDimensions
doError, doRelease, getAllowedMethods, getApplication, getChallengeRequests, getChallengeResponse, getClientInfo, getConditions, getConnegService, getContext, getConverterService, getCookies, getCookieSettings, getDimensions, getHostRef, getLocationRef, getLogger, getMatrix, getMatrixValue, getMaxForwards, getMetadataService, getMethod, getOriginalRef, getProtocol, getProxyChallengeRequests, getProxyChallengeResponse, getQuery, getQueryValue, getRanges, getReference, getReferrerRef, getRequest, getRequestAttributes, getRequestCacheDirectives, getRequestEntity, getResponse, getResponseAttributes, getResponseCacheDirectives, getResponseEntity, getRootRef, getServerInfo, getStatus, getStatusService, init, isConfidential, isLoggable, release, setApplication, setQueryValue, setRequest, setResponse, toBoolean, toByte, toDouble, toFloat, toInteger, toLong, toObject, toRepresentation, toRepresentation, toRepresentation, toShort, toString
protected void doCatch(Throwable t)
doCatch
in class ServerResource
t
- protected void ensureGrantTypeAllowed(org.restlet.ext.oauth.internal.Client client, GrantType grantType) throws OAuthException
OAuthException
protected org.restlet.ext.oauth.internal.Client getAuthenticatedClient() throws OAuthException
OAuthException
protected org.restlet.ext.oauth.internal.Client getClient(Form params) throws OAuthException
OAuthServerResource
getClient
in class OAuthServerResource
OAuthException
protected String getCode(Form params) throws OAuthException
params
- OAuthException
protected GrantType getGrantType(Form params) throws OAuthException
params
- OAuthException
protected String getPassword(Form params) throws OAuthException
params
- OAuthException
protected String getRedirectURI(Form params) throws OAuthException
params
- OAuthException
protected String getRefreshToken(Form params) throws OAuthException
params
- OAuthException
protected String getUsername(Form params) throws OAuthException
params
- OAuthException
@Post(value="form:json") public Representation requestToken(Representation input) throws OAuthException, JSONException
Post
request. The client MUST use the HTTP "POST"
method when making access token requests. (3.2. Token Endpoint)input
- HTML form formated token request per oauth-v2 spec.OAuthException
JSONException
protected Representation responseTokenRepresentation(org.restlet.ext.oauth.internal.Token token, String[] requestedScope) throws JSONException
token
- The token generated by the client.requestedScope
- The scope originally requested by the client.ResourceException
JSONException
Copyright © 2005-2014 Restlet.