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

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

public class BrowserClientRequestUrl
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 the access token to a browser client using a scripting language such as JavaScript, as specified in Implicit Grant.

The default for AuthorizationRequestUrl.getResponseTypes() is "token".

Sample usage for a web application:

  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String url = new BrowserClientRequestUrl(
        "https://server.example.com/authorize", "s6BhdRkqt3").setState("xyz")
        .setRedirectUri("https://client.example.com/cb").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
BrowserClientRequestUrl(String encodedAuthorizationServerUrl, String clientId)
           
 
Method Summary
 BrowserClientRequestUrl setClientId(String clientId)
          Sets the client identifier.
 BrowserClientRequestUrl 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.
 BrowserClientRequestUrl 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).
 BrowserClientRequestUrl 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).
 BrowserClientRequestUrl setScopes(Iterable<String> scopes)
          Sets the list of scopes (as specified in Access Token Scope) or null for none.
 BrowserClientRequestUrl setScopes(String... scopes)
          Sets the list of scopes (as specified in Access Token Scope) or null for none.
 BrowserClientRequestUrl 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

BrowserClientRequestUrl

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

setResponseTypes

public BrowserClientRequestUrl 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 BrowserClientRequestUrl 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 BrowserClientRequestUrl 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 BrowserClientRequestUrl 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 BrowserClientRequestUrl 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 BrowserClientRequestUrl 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 BrowserClientRequestUrl 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.