Class AuthorizationCodeRequestUrl (1.36.0)

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
Name Description
authorizationServerEncodedUrl String

authorization server encoded URL

clientId String

client identifier

Methods

clone()

public AuthorizationCodeRequestUrl clone()
Returns
Type Description
AuthorizationCodeRequestUrl
Overrides

getCodeChallenge()

public String getCodeChallenge()

Get the code challenge (details).

Returns
Type Description
String

getCodeChallengeMethod()

public String getCodeChallengeMethod()

Get the code challenge method (details).

Returns
Type Description
String

set(String fieldName, Object value)

public AuthorizationCodeRequestUrl set(String fieldName, Object value)
Parameters
Name Description
fieldName String
value Object
Returns
Type Description
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
Name Description
clientId String
Returns
Type Description
AuthorizationCodeRequestUrl
Overrides

setCodeChallenge(String codeChallenge)

public void setCodeChallenge(String codeChallenge)

Set the code challenge (details).

Parameter
Name Description
codeChallenge String

the code challenge.

setCodeChallengeMethod(String codeChallengeMethod)

public void setCodeChallengeMethod(String codeChallengeMethod)

Set the code challenge method (details).

Parameter
Name Description
codeChallengeMethod String

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
Name Description
redirectUri String
Returns
Type Description
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
Name Description
responseTypes Collection<String>
Returns
Type Description
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
Name Description
scopes Collection<String>
Returns
Type Description
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
Name Description
state String
Returns
Type Description
AuthorizationCodeRequestUrl
Overrides