Class AuthorizationRequestUrl
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.AuthorizationRequestUrl
- Direct Known Subclasses:
AuthorizationCodeRequestUrl, BrowserClientRequestUrl
public class AuthorizationRequestUrl
extends com.google.api.client.http.GenericUrl
OAuth 2.0 URL builder for an authorization web page to allow the end user to authorize the
application to access their protected resources, as specified in Authorization Endpoint.
Sample usage for a web application:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
String url = new AuthorizationRequestUrl(
"https://server.example.com/authorize", "s6BhdRkqt3", Arrays.asList("code")).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.FlagsNested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringClient identifier.private StringURI 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) ornullfor none.private StringResponse type, which must be"code"for requesting an authorization code,"token"for requesting an access token (implicit grant), or space-separated registered extension values.private StringSpace-separated list of scopes (as specified in Access Token Scope) ornullfor none.private StringState (an opaque value used by the client to maintain state between the request and callback, as mentioned in Registration Requirements) ornullfor none. -
Constructor Summary
ConstructorsConstructorDescriptionAuthorizationRequestUrl(String authorizationServerEncodedUrl, String clientId, Collection<String> responseTypes) -
Method Summary
Modifier and TypeMethodDescriptionclone()final StringReturns the client identifier.final StringReturns 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) ornullfor none.final StringReturns the Response type, which must be"code"for requesting an authorization code,"token"for requesting an access token (implicit grant), or space-separated registered extension values.final StringReturns the space-separated list of scopes (as specified in Access Token Scope) ornullfor none.final StringgetState()Returns the state (an opaque value used by the client to maintain state between the request and callback, as mentioned in Registration Requirements) ornullfor none.setClientId(String clientId) Sets the client identifier.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) ornullfor none.setResponseTypes(Collection<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.setScopes(Collection<String> scopes) Sets the list of scopes (as specified in Access Token Scope) ornullfor none.Sets the state (an opaque value used by the client to maintain state between the request and callback, as mentioned in Registration Requirements) ornullfor 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, toURLMethods inherited from class com.google.api.client.util.GenericData
entrySet, get, getClassInfo, getUnknownKeys, put, putAll, remove, setUnknownKeysMethods inherited from class AbstractMap
clear, containsKey, containsValue, isEmpty, keySet, size, valuesMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
responseTypes
Response type, which must be"code"for requesting an authorization code,"token"for requesting an access token (implicit grant), or space-separated registered extension values. -
redirectUri
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) ornullfor none. -
scopes
Space-separated list of scopes (as specified in Access Token Scope) ornullfor none. -
clientId
Client identifier. -
state
State (an opaque value used by the client to maintain state between the request and callback, as mentioned in Registration Requirements) ornullfor none.
-
-
Constructor Details
-
AuthorizationRequestUrl
public AuthorizationRequestUrl(String authorizationServerEncodedUrl, String clientId, Collection<String> responseTypes) - Parameters:
authorizationServerEncodedUrl- authorization server encoded URLclientId- client identifierresponseTypes- 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- Since:
- 1.15
-
-
Method Details
-
getResponseTypes
Returns the Response type, which must be"code"for requesting an authorization code,"token"for requesting an access token (implicit grant), or space-separated registered extension values. -
setResponseTypes
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.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Since:
- 1.15
-
getRedirectUri
Returns 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) ornullfor none. -
setRedirectUri
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) ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
-
getScopes
Returns the space-separated list of scopes (as specified in Access Token Scope) ornullfor none. -
setScopes
Sets the list of scopes (as specified in Access Token Scope) ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Parameters:
scopes- collection of scopes to be joined by a space separator (or a single value containing multiple space-separated scopes) ornullfor none- Since:
- 1.15
-
getClientId
Returns the client identifier. -
setClientId
Sets the client identifier.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
-
getState
Returns the state (an opaque value used by the client to maintain state between the request and callback, as mentioned in Registration Requirements) ornullfor none. -
setState
Sets the state (an opaque value used by the client to maintain state between the request and callback, as mentioned in Registration Requirements) ornullfor none.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
-
set
- Overrides:
setin classcom.google.api.client.http.GenericUrl
-
clone
- Overrides:
clonein classcom.google.api.client.http.GenericUrl
-