com.google.api.client.auth.oauth2.draft10
Class AuthorizationRequestUrl

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.draft10.AuthorizationRequestUrl
All Implemented Interfaces:
Cloneable, Map<String,Object>

public class AuthorizationRequestUrl
extends GenericUrl

OAuth 2.0 (draft 10) URL builder for an authorization web page to allow the end user to authorize the application to access their protected resources as specified in Obtaining End-User Authorization.

Use AuthorizationResponse to parse the redirect response after the end user grants/denies the request.

Sample usage for a web application:

 
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    AuthorizationRequestUrl builder =
        new AuthorizationRequestUrl(BASE_AUTHORIZATION_URL, CLIENT_ID);
    builder.redirectUri = REDIRECT_URL;
    builder.scope = SCOPE;
    response.sendRedirect(builder.build());
    return;
  }
 
 

Since:
1.4
Author:
Yaniv Inbar

Nested Class Summary
static class AuthorizationRequestUrl.ResponseType
          Response type enumeration that may be used for setting the responseType.
 
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
 String clientId
          (REQUIRED) The client identifier.
 String redirectUri
          (REQUIRED, unless a redirection URI has been established between the client and authorization server via other means) An absolute URI to which the authorization server will redirect the user-agent to when the end-user authorization step is completed.
 String responseType
          (REQUIRED) The requested response: an access token, an authorization code, or both.
 String scope
          (OPTIONAL) The scope of the access request expressed as a list of space-delimited strings.
 String state
          (OPTIONAL) An opaque value used by the client to maintain state between the request and callback.
 
Fields inherited from class com.google.api.client.http.GenericUrl
fragment, host, pathParts, port, scheme
 
Fields inherited from class com.google.api.client.util.GenericData
unknownFields
 
Constructor Summary
AuthorizationRequestUrl(String encodedAuthorizationServerUrl)
           
AuthorizationRequestUrl(String encodedAuthorizationServerUrl, String clientId)
           
 
Method Summary
 
Methods inherited from class com.google.api.client.http.GenericUrl
appendRawPath, build, clone, equals, getAll, getFirst, getRawPath, hashCode, setRawPath, toPathParts, toString
 
Methods inherited from class com.google.api.client.util.GenericData
entrySet, get, put, putAll, remove, set
 
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 Detail

responseType

public String responseType
(REQUIRED) The requested response: an access token, an authorization code, or both. The parameter value MUST be set to "token" for requesting an access token, "code" for requesting an authorization code, or "code_and_token" to request both. The authorization server MAY decline to provide one or more of these response types. For convenience, you may use AuthorizationRequestUrl.ResponseType to set this value.

By default, the response type is "code", but this may be overridden.


clientId

public String clientId
(REQUIRED) The client identifier.


redirectUri

public String redirectUri
(REQUIRED, unless a redirection URI has been established between the client and authorization server via other means) An absolute URI to which the authorization server will redirect the user-agent to when the end-user authorization step is completed. The authorization server SHOULD require the client to pre-register their redirection URI.


scope

public String scope
(OPTIONAL) The scope of the access request expressed as a list of space-delimited strings. The value of the "scope" parameter is defined by the authorization server. If the value contains multiple space-delimited strings, their order does not matter, and each string adds an additional access range to the requested scope.


state

public String state
(OPTIONAL) An opaque value used by the client to maintain state between the request and callback. The authorization server includes this value when redirecting the user-agent back to the client.

Constructor Detail

AuthorizationRequestUrl

public AuthorizationRequestUrl(String encodedAuthorizationServerUrl)
Parameters:
encodedAuthorizationServerUrl - encoded authorization server URL

AuthorizationRequestUrl

public AuthorizationRequestUrl(String encodedAuthorizationServerUrl,
                               String clientId)
Parameters:
encodedAuthorizationServerUrl - encoded authorization server URL
clientId - client identifier


Copyright © 2010-2011 Google. All Rights Reserved.