# Class AuthorizationCodeRequestUrl (1.39.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [1.39.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl)
- [1.38.2](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.38.2/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl)
- [1.37.0](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.37.0/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl)
- [1.36.0](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.36.0/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl)
- [1.34.1](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.34.1/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl)
- [1.33.3](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.33.3/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl)
- [1.32.1](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.32.1/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl)

    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](http://tools.ietf.org/html/rfc6749#section-4.1).

The default for #getResponseTypes() is `"code"`. Use [AuthorizationCodeResponseUrl](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeResponseUrl) to parse the redirect response after the end user grants/denies the
request. Using the authorization code in this response, use [AuthorizationCodeTokenRequest](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.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](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> java.util.AbstractMap \> com.google.api.client.util.GenericData \> com.google.api.client.http.GenericUrl \> [AuthorizationRequestUrl](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl) \> AuthorizationCodeRequestUrl

## Inherited Members

[AuthorizationRequestUrl.clone()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_clone__) [AuthorizationRequestUrl.getClientId()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_getClientId__) [AuthorizationRequestUrl.getRedirectUri()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_getRedirectUri__) [AuthorizationRequestUrl.getResponseTypes()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_getResponseTypes__) [AuthorizationRequestUrl.getScopes()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_getScopes__) [AuthorizationRequestUrl.getState()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_getState__) [AuthorizationRequestUrl.set(String,Object)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_set_java_lang_String_java_lang_Object_) [AuthorizationRequestUrl.setClientId(String)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_setClientId_java_lang_String_) [AuthorizationRequestUrl.setRedirectUri(String)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_setRedirectUri_java_lang_String_) [AuthorizationRequestUrl.setResponseTypes(Collection\<String\>)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_setResponseTypes_java_util_Collection_java_lang_String__) [AuthorizationRequestUrl.setScopes(Collection\<String\>)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_setScopes_java_util_Collection_java_lang_String__) [AuthorizationRequestUrl.setState(String)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_setState_java_lang_String_) com.google.api.client.http.GenericUrl.appendRawPath(java.lang.String) com.google.api.client.http.GenericUrl.build() com.google.api.client.http.GenericUrl.buildAuthority() com.google.api.client.http.GenericUrl.buildRelativeUrl() com.google.api.client.http.GenericUrl.equals(java.lang.Object) com.google.api.client.http.GenericUrl.getAll(java.lang.String) com.google.api.client.http.GenericUrl.getFirst(java.lang.String) com.google.api.client.http.GenericUrl.getFragment() com.google.api.client.http.GenericUrl.getHost() com.google.api.client.http.GenericUrl.getPathParts() com.google.api.client.http.GenericUrl.getPort() com.google.api.client.http.GenericUrl.getRawPath() com.google.api.client.http.GenericUrl.getScheme() com.google.api.client.http.GenericUrl.getUserInfo() com.google.api.client.http.GenericUrl.hashCode() com.google.api.client.http.GenericUrl.setFragment(java.lang.String) com.google.api.client.http.GenericUrl.setHost(java.lang.String) com.google.api.client.http.GenericUrl.setPathParts(java.util.List\<java.lang.String\>) com.google.api.client.http.GenericUrl.setPort(int) com.google.api.client.http.GenericUrl.setRawPath(java.lang.String) com.google.api.client.http.GenericUrl.setScheme(java.lang.String) com.google.api.client.http.GenericUrl.setUserInfo(java.lang.String) com.google.api.client.http.GenericUrl.toPathParts(java.lang.String) com.google.api.client.http.GenericUrl.toPathParts(java.lang.String,boolean) com.google.api.client.http.GenericUrl.toString() com.google.api.client.http.GenericUrl.toURI() com.google.api.client.http.GenericUrl.toURL() com.google.api.client.http.GenericUrl.toURL(java.lang.String) com.google.api.client.util.GenericData.entrySet() com.google.api.client.util.GenericData.get(java.lang.Object) com.google.api.client.util.GenericData.getClassInfo() com.google.api.client.util.GenericData.getUnknownKeys() com.google.api.client.util.GenericData.put(java.lang.String,java.lang.Object) com.google.api.client.util.GenericData.putAll(java.util.Map\<? extends java.lang.String,?\>) com.google.api.client.util.GenericData.remove(java.lang.Object) com.google.api.client.util.GenericData.setUnknownKeys(java.util.Map\<java.lang.String,java.lang.Object\>) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-) [AbstractMap.clear()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#clear--) [AbstractMap.containsKey(Object)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#containsKey-java.lang.Object-) [AbstractMap.containsValue(Object)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#containsValue-java.lang.Object-) [AbstractMap.isEmpty()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#isEmpty--) [AbstractMap.keySet()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#keySet--) [AbstractMap.put(K,V)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#put-K-V-) [AbstractMap.putAll(Map\<? extends K,? extends V\>)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#putAll-java.util.Map<? extends K-? extends V>-) [AbstractMap.size()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#size--) [AbstractMap.values()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#values--)

## Constructors

### AuthorizationCodeRequestUrl(String authorizationServerEncodedUrl, String clientId)

    public AuthorizationCodeRequestUrl(String authorizationServerEncodedUrl, String clientId)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `authorizationServerEncodedUrl` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` authorization server encoded URL |
| `clientId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` client identifier |

## Methods

### clone()

    public AuthorizationCodeRequestUrl clone()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl` |   |

**Overrides** [AuthorizationRequestUrl.clone()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_clone__)

### getCodeChallenge()

    public String getCodeChallenge()

Get the code challenge ([details](https://tools.ietf.org/html/rfc7636#section-4.3)).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getCodeChallengeMethod()

    public String getCodeChallengeMethod()

Get the code challenge method ([details](https://tools.ietf.org/html/rfc7636#section-4.3)).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### set(String fieldName, Object value)

    public AuthorizationCodeRequestUrl set(String fieldName, Object value)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `fieldName` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl` |   |

**Overrides** [AuthorizationRequestUrl.set(String fieldName, Object value)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_set_java_lang_String_java_lang_Object_)

### 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl` |   |

**Overrides** [AuthorizationRequestUrl.setClientId(String clientId)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_setClientId_java_lang_String_)

### setCodeChallenge(String codeChallenge)

    public void setCodeChallenge(String codeChallenge)

Set the code challenge ([details](https://tools.ietf.org/html/rfc7636#section-4.3)).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `codeChallenge` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` the code challenge. |

### setCodeChallengeMethod(String codeChallengeMethod)

    public void setCodeChallengeMethod(String codeChallengeMethod)

Set the code challenge method ([details](https://tools.ietf.org/html/rfc7636#section-4.3)).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `codeChallengeMethod` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` 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](http://tools.ietf.org/html/rfc6749#section-3.1.2)) 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl` |   |

**Overrides** [AuthorizationRequestUrl.setRedirectUri(String redirectUri)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_setRedirectUri_java_lang_String_)

### setResponseTypes(Collection\<String\> responseTypes)

    public AuthorizationCodeRequestUrl setResponseTypes(Collection<String> responseTypes)

Sets the [response type](http://tools.ietf.org/html/rfc6749#section-3.1.1), 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` | `https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl` |   |

**Overrides** [AuthorizationRequestUrl.setResponseTypes(Collection\<String\> responseTypes)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_setResponseTypes_java_util_Collection_java_lang_String__)

### setScopes(Collection\<String\> scopes)

    public AuthorizationCodeRequestUrl setScopes(Collection<String> scopes)

Sets the list of scopes (as specified in [Access Token Scope](http://tools.ietf.org/html/rfc6749#section-3.3)) 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` | `https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl` |   |

**Overrides** [AuthorizationRequestUrl.setScopes(Collection\<String\> scopes)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_setScopes_java_util_Collection_java_lang_String__)

### 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](http://tools.ietf.org/html/rfc6749#section-3.1.2.2)) 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` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl` |   |

**Overrides** [AuthorizationRequestUrl.setState(String state)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationRequestUrl#com_google_api_client_auth_oauth2_AuthorizationRequestUrl_setState_java_lang_String_)