Class AuthorizationCodeRequestUrl (1.32.1)

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 #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.

Inheritance

Object > java.util.AbstractMap > com.google.api.client.util.GenericData > com.google.api.client.http.GenericUrl > AuthorizationRequestUrl > AuthorizationCodeRequestUrl

Constructors

AuthorizationCodeRequestUrl(String authorizationServerEncodedUrl, String clientId)

public AuthorizationCodeRequestUrl(String authorizationServerEncodedUrl, String clientId)
Parameters
NameDescription
authorizationServerEncodedUrlString

authorization server encoded URL

clientIdString

client identifier

Methods

clone()

public AuthorizationCodeRequestUrl clone()
Returns
TypeDescription
AuthorizationCodeRequestUrl
Overrides

getCodeChallenge()

public String getCodeChallenge()

Get the code challenge (details).

Returns
TypeDescription
String

getCodeChallengeMethod()

public String getCodeChallengeMethod()

Get the code challenge method (details).

Returns
TypeDescription
String

set(String fieldName, Object value)

public AuthorizationCodeRequestUrl set(String fieldName, Object value)
Parameters
NameDescription
fieldNameString
valueObject
Returns
TypeDescription
AuthorizationCodeRequestUrl
Overrides

setClientId(String clientId)

public AuthorizationCodeRequestUrl setClientId(String clientId)

Sets the client identifier.

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

Parameter
NameDescription
clientIdString
Returns
TypeDescription
AuthorizationCodeRequestUrl
Overrides

setCodeChallenge(String codeChallenge)

public void setCodeChallenge(String codeChallenge)

Set the code challenge (details).

Parameter
NameDescription
codeChallengeString

the code challenge.

setCodeChallengeMethod(String codeChallengeMethod)

public void setCodeChallengeMethod(String codeChallengeMethod)

Set the code challenge method (details).

Parameter
NameDescription
codeChallengeMethodString

the code challenge method.

setRedirectUri(String redirectUri)

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

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

Parameter
NameDescription
redirectUriString
Returns
TypeDescription
AuthorizationCodeRequestUrl
Overrides

setResponseTypes(Collection<String> responseTypes)

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

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

Parameter
NameDescription
responseTypesCollection<String>
Returns
TypeDescription
AuthorizationCodeRequestUrl
Overrides

setScopes(Collection<String> scopes)

public AuthorizationCodeRequestUrl setScopes(Collection<String> scopes)

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.

Parameter
NameDescription
scopesCollection<String>
Returns
TypeDescription
AuthorizationCodeRequestUrl
Overrides

setState(String state)

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

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

Parameter
NameDescription
stateString
Returns
TypeDescription
AuthorizationCodeRequestUrl
Overrides