com.google.api.client.auth.oauth2
Class AuthorizationCodeRequestUrl

java.lang.Object
  extended by java.util.AbstractMap<String,Object>
      extended by com.google.api.client.util.GenericData
          extended by com.google.api.client.http.GenericUrl
              extended by com.google.api.client.auth.oauth2.AuthorizationRequestUrl
                  extended by com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl
All Implemented Interfaces:
Cloneable, Map<String,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
Author:
Yaniv Inbar

Nested Class Summary
 
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>
 
Constructor Summary
AuthorizationCodeRequestUrl(String authorizationServerEncodedUrl, String clientId)
           
 
Method Summary
 AuthorizationCodeRequestUrl setClientId(String clientId)
          Sets the client identifier.
 AuthorizationCodeRequestUrl setRedirectUri(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(Iterable<String> responseTypes)
          Sets the list of response types, each of which must be "code", "token", or a registered extension value (as specified in Response Type).
 AuthorizationCodeRequestUrl setResponseTypes(String... responseTypes)
          Sets the list of response types, each of which must be "code", "token", or a registered extension value (as specified in Response Type).
 AuthorizationCodeRequestUrl setScopes(Iterable<String> scopes)
          Sets the list of scopes (as specified in Access Token Scope) or null for none.
 AuthorizationCodeRequestUrl setScopes(String... scopes)
          Sets the list of scopes (as specified in Access Token Scope) or null for none.
 AuthorizationCodeRequestUrl setState(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.auth.oauth2.AuthorizationRequestUrl
getClientId, getRedirectUri, getResponseTypes, getScopes, getState
 
Methods inherited from class com.google.api.client.http.GenericUrl
appendRawPath, build, clone, equals, getAll, getFirst, getFragment, getHost, getPathParts, getPort, getRawPath, getScheme, hashCode, setFragment, setHost, setPathParts, setPort, setRawPath, setScheme, toPathParts, toString
 
Methods inherited from class com.google.api.client.util.GenericData
entrySet, get, getUnknownKeys, put, putAll, remove, set, 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
 

Constructor Detail

AuthorizationCodeRequestUrl

public AuthorizationCodeRequestUrl(String authorizationServerEncodedUrl,
                                   String clientId)
Parameters:
authorizationServerEncodedUrl - authorization server encoded URL
clientId - client identifier
Method Detail

setResponseTypes

public AuthorizationCodeRequestUrl setResponseTypes(String... responseTypes)
Description copied from class: AuthorizationRequestUrl
Sets the list of response types, each of which must be "code", "token", or a registered extension value (as specified in Response Type).

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Overrides:
setResponseTypes in class AuthorizationRequestUrl
Parameters:
responseTypes - response types to be joined by a space separator (or a single value containing multiple space-separated scopes)

setResponseTypes

public AuthorizationCodeRequestUrl setResponseTypes(Iterable<String> responseTypes)
Description copied from class: AuthorizationRequestUrl
Sets the list of response types, each of which must be "code", "token", or a registered extension value (as specified in Response Type).

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Overrides:
setResponseTypes in class AuthorizationRequestUrl
Parameters:
responseTypes - response types to be joined by a space separator (or a single value containing multiple space-separated scopes)

setRedirectUri

public AuthorizationCodeRequestUrl setRedirectUri(String redirectUri)
Description copied from class: AuthorizationRequestUrl
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.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Overrides:
setRedirectUri in class AuthorizationRequestUrl

setScopes

public AuthorizationCodeRequestUrl setScopes(String... scopes)
Description copied from class: AuthorizationRequestUrl
Sets the list of scopes (as specified in Access Token Scope) or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Overrides:
setScopes in class AuthorizationRequestUrl
Parameters:
scopes - list of scopes to be joined by a space separator (or a single value containing multiple space-separated scopes) or null for none

setScopes

public AuthorizationCodeRequestUrl setScopes(Iterable<String> scopes)
Description copied from class: AuthorizationRequestUrl
Sets the list of scopes (as specified in Access Token Scope) or null for none.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Overrides:
setScopes in class AuthorizationRequestUrl
Parameters:
scopes - list of scopes to be joined by a space separator (or a single value containing multiple space-separated scopes) or null for none

setClientId

public AuthorizationCodeRequestUrl setClientId(String clientId)
Description copied from class: AuthorizationRequestUrl
Sets the client identifier.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Overrides:
setClientId in class AuthorizationRequestUrl

setState

public AuthorizationCodeRequestUrl setState(String state)
Description copied from class: AuthorizationRequestUrl
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.

Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.

Overrides:
setState in class AuthorizationRequestUrl


Copyright © 2011-2012 Google. All Rights Reserved.