Class AuthorizationCodeRequestUrl

  • All Implemented Interfaces:
    java.lang.Cloneable, java.util.Map<java.lang.String,​java.lang.Object>

    public class AuthorizationCodeRequestUrl
    extends AuthorizationRequestUrl
    OAuth 2.0 URL builder for an authorization web page to allow the end user to authorize the application to access their protected resources and that returns an authorization code, as specified in Authorization Code Grant.

    The default for AuthorizationRequestUrl.getResponseTypes() is "code". Use AuthorizationCodeResponseUrl to parse the redirect response after the end user grants/denies the request. Using the authorization code in this response, use AuthorizationCodeTokenRequest to request the access token.

    Sample usage for a web application:

      public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        String url =
            new AuthorizationCodeRequestUrl("https://server.example.com/authorize", "s6BhdRkqt3")
                .setState("xyz").setRedirectUri("https://client.example.com/rd").build();
        response.sendRedirect(url);
      }
     

    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

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      AuthorizationCodeRequestUrl​(java.lang.String authorizationServerEncodedUrl, java.lang.String clientId)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      AuthorizationCodeRequestUrl clone()  
      AuthorizationCodeRequestUrl set​(java.lang.String fieldName, java.lang.Object value)  
      AuthorizationCodeRequestUrl setClientId​(java.lang.String clientId)
      Sets the client identifier.
      AuthorizationCodeRequestUrl setRedirectUri​(java.lang.String redirectUri)
      Sets the URI that the authorization server directs the resource owner's user-agent back to the client after a successful authorization grant (as specified in Redirection Endpoint) or null for none.
      AuthorizationCodeRequestUrl setResponseTypes​(java.util.Collection<java.lang.String> responseTypes)
      Sets the response type, which must be "code" for requesting an authorization code, "token" for requesting an access token (implicit grant), or a list of registered extension values to join with a space.
      AuthorizationCodeRequestUrl setScopes​(java.util.Collection<java.lang.String> scopes)
      Sets the list of scopes (as specified in Access Token Scope) or null for none.
      AuthorizationCodeRequestUrl setState​(java.lang.String state)
      Sets the state (an opaque value used by the client to maintain state between the request and callback, as mentioned in Registration Requirements) 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
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
    • Constructor Detail

      • AuthorizationCodeRequestUrl

        public AuthorizationCodeRequestUrl​(java.lang.String authorizationServerEncodedUrl,
                                           java.lang.String clientId)
        Parameters:
        authorizationServerEncodedUrl - authorization server encoded URL
        clientId - client identifier