public class AuthorizationCodeResponseUrl extends GenericUrl
OAuth 2.0 URL parser for the redirect URL after end user grants or denies authorization as specified in Authorization Response.
Check if #getError() is null
to check if the end-user granted authorization.
Sample usage:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { StringBuffer fullUrlBuf = request.getRequestURL(); if (request.getQueryString() != null) { fullUrlBuf.append('?').append(request.getQueryString()); } AuthorizationCodeResponseUrl authResponse = new AuthorizationCodeResponseUrl(fullUrlBuf.toString()); // check for user-denied error if (authResponse.getError() != null) { // authorization denied... } else { // request access token using authResponse.getCode()... } }
Implementation is not thread-safe.
Inheritance
Object > java.util.AbstractMap > com.google.api.client.util.GenericData > com.google.api.client.http.GenericUrl > AuthorizationCodeResponseUrlConstructors
AuthorizationCodeResponseUrl(String encodedResponseUrl)
public AuthorizationCodeResponseUrl(String encodedResponseUrl)
Parameter | |
---|---|
Name | Description |
encodedResponseUrl |
String encoded authorization code response URL |
Methods
clone()
public AuthorizationCodeResponseUrl clone()
Returns | |
---|---|
Type | Description |
AuthorizationCodeResponseUrl |
getCode()
public final String getCode()
Returns the authorization code generated by the authorization server or null
for none.
Returns | |
---|---|
Type | Description |
String |
getError()
public final String getError()
Returns the error code ("invalid_request"
, "unauthorized_client"
,
"access_denied"
, "unsupported_response_type"
, "invalid_scope"
,
"server_error"
, "temporarily_unavailable"
, or an extension error code as specified in
Defining Additional Error Codes)
or null
for none.
Returns | |
---|---|
Type | Description |
String |
getErrorDescription()
public final String getErrorDescription()
Returns the human-readable text providing additional information used to assist the client
developer in understanding the error that occurred or null
for none.
Returns | |
---|---|
Type | Description |
String |
getErrorUri()
public final String getErrorUri()
Returns the URI identifying a human-readable web page with information about the error used to
provide the client developer with additional information about the error or null
for
none.
Returns | |
---|---|
Type | Description |
String |
getState()
public final String getState()
Returns the state parameter matching the state parameter in the authorization request or
null
for none.
Returns | |
---|---|
Type | Description |
String |
set(String fieldName, Object value)
public AuthorizationCodeResponseUrl set(String fieldName, Object value)
Parameters | |
---|---|
Name | Description |
fieldName |
String |
value |
Object |
Returns | |
---|---|
Type | Description |
AuthorizationCodeResponseUrl |
setCode(String code)
public AuthorizationCodeResponseUrl setCode(String code)
Sets the authorization code generated by the authorization server or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
code |
String |
Returns | |
---|---|
Type | Description |
AuthorizationCodeResponseUrl |
setError(String error)
public AuthorizationCodeResponseUrl setError(String error)
Sets the error code ("invalid_request"
, "unauthorized_client"
,
"access_denied"
, "unsupported_response_type"
, "invalid_scope"
,
"server_error"
, "temporarily_unavailable"
, or an extension error code as specified in
Defining Additional Error Codes)
or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
error |
String |
Returns | |
---|---|
Type | Description |
AuthorizationCodeResponseUrl |
setErrorDescription(String errorDescription)
public AuthorizationCodeResponseUrl setErrorDescription(String errorDescription)
Sets the human-readable text providing additional information used to assist the client
developer in understanding the error that occurred or null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
errorDescription |
String |
Returns | |
---|---|
Type | Description |
AuthorizationCodeResponseUrl |
setErrorUri(String errorUri)
public AuthorizationCodeResponseUrl setErrorUri(String errorUri)
Sets the URI identifying a human-readable web page with information about the error used to
provide the client developer with additional information about the error or null
for
none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
errorUri |
String |
Returns | |
---|---|
Type | Description |
AuthorizationCodeResponseUrl |
setState(String state)
public AuthorizationCodeResponseUrl setState(String state)
Sets the state parameter matching the state parameter in the authorization request or
null
for none.
Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
Parameter | |
---|---|
Name | Description |
state |
String |
Returns | |
---|---|
Type | Description |
AuthorizationCodeResponseUrl |