Class AuthorizationCodeResponseUrl

java.lang.Object
java.util.AbstractMap<String,Object>
com.google.api.client.util.GenericData
com.google.api.client.http.GenericUrl
com.google.api.client.auth.oauth2.AuthorizationCodeResponseUrl
All Implemented Interfaces:
Cloneable, Map<String,Object>

public class AuthorizationCodeResponseUrl extends com.google.api.client.http.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.

Since:
1.7
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.google.api.client.util.GenericData

    com.google.api.client.util.GenericData.Flags

    Nested classes/interfaces inherited from class java.util.AbstractMap

    AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>

    Nested classes/interfaces inherited from interface java.util.Map

    Map.Entry<K,V>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    Authorization code generated by the authorization server or null for none.
    private String
    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.
    private String
    Human-readable text providing additional information used to assist the client developer in understanding the error that occurred or null for none.
    private String
    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.
    private String
    State parameter matching the state parameter in the authorization request or null for none.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    final String
    Returns the authorization code generated by the authorization server or null for none.
    final String
    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.
    final String
    Returns the human-readable text providing additional information used to assist the client developer in understanding the error that occurred or null for none.
    final String
    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.
    final String
    Returns the state parameter matching the state parameter in the authorization request or null for none.
    set(String fieldName, Object value)
     
    Sets the authorization code generated by the authorization server or null for none.
    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.
    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.
    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.
    Sets the state parameter matching the state parameter in the authorization request or null for none.

    Methods inherited from class com.google.api.client.http.GenericUrl

    appendRawPath, build, buildAuthority, buildRelativeUrl, equals, getAll, getFirst, getFragment, getHost, getPathParts, getPort, getRawPath, getScheme, getUserInfo, hashCode, setFragment, setHost, setPathParts, setPort, setRawPath, setScheme, setUserInfo, toPathParts, toString, toURI, toURL, toURL

    Methods inherited from class com.google.api.client.util.GenericData

    entrySet, get, getClassInfo, getUnknownKeys, put, putAll, remove, setUnknownKeys

    Methods inherited from class java.util.AbstractMap

    clear, containsKey, containsValue, isEmpty, keySet, size, values

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • code

      private String code
      Authorization code generated by the authorization server or null for none.
    • state

      private String state
      State parameter matching the state parameter in the authorization request or null for none.
    • error

      private String error
      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.
    • errorDescription

      private String errorDescription
      Human-readable text providing additional information used to assist the client developer in understanding the error that occurred or null for none.
    • errorUri

      private String errorUri
      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.
  • Constructor Details

    • AuthorizationCodeResponseUrl

      public AuthorizationCodeResponseUrl(String encodedResponseUrl)
      Parameters:
      encodedResponseUrl - encoded authorization code response URL
  • Method Details

    • getCode

      public final String getCode()
      Returns the authorization code generated by the authorization server or null for none.
    • setCode

      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.

    • getState

      public final String getState()
      Returns the state parameter matching the state parameter in the authorization request or null for none.
    • setState

      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.

    • 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.
    • setError

      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.

    • 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.
    • setErrorDescription

      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.

    • 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.
    • setErrorUri

      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.

    • set

      public AuthorizationCodeResponseUrl set(String fieldName, Object value)
      Overrides:
      set in class com.google.api.client.http.GenericUrl
    • clone

      Overrides:
      clone in class com.google.api.client.http.GenericUrl