# Class AuthorizationCodeInstalledApp (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.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)
- [1.38.2](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.38.2/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)
- [1.37.0](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.37.0/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)
- [1.36.0](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.36.0/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)
- [1.34.1](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.34.1/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)
- [1.33.3](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.33.3/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)
- [1.32.1](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.32.1/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp)

    public class AuthorizationCodeInstalledApp

OAuth 2.0 authorization code flow for an installed Java application that persists end-user
credentials.

Implementation is thread-safe.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> AuthorizationCodeInstalledApp

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-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.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [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.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [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-)

## Static Methods

### browse(String url)

    public static void browse(String url)

Open a browser at the given URL using Desktop if available, or alternatively output the
URL to System#out for command-line applications.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `url` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` URL to browse |

## Constructors

### AuthorizationCodeInstalledApp(AuthorizationCodeFlow flow, VerificationCodeReceiver receiver)

    public AuthorizationCodeInstalledApp(AuthorizationCodeFlow flow, VerificationCodeReceiver receiver)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `flow` | `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeFlow` authorization code flow |
| `receiver` | `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.extensions.java6.auth.oauth2.VerificationCodeReceiver` verification code receiver |

### AuthorizationCodeInstalledApp(AuthorizationCodeFlow flow, VerificationCodeReceiver receiver, AuthorizationCodeInstalledApp.Browser browser)

    public AuthorizationCodeInstalledApp(AuthorizationCodeFlow flow, VerificationCodeReceiver receiver, AuthorizationCodeInstalledApp.Browser browser)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `flow` | `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeFlow` authorization code flow |
| `receiver` | `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.extensions.java6.auth.oauth2.VerificationCodeReceiver` verification code receiver |
| `browser` | `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.Browser` |

## Methods

### authorize(String userId)

    public Credential authorize(String userId)

Authorizes the installed application to access user's protected data.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `userId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` user ID or `null` if not using a persisted credential store |

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

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### getFlow()

    public final AuthorizationCodeFlow getFlow()

Returns the authorization code flow.

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

### getReceiver()

    public final VerificationCodeReceiver getReceiver()

Returns the verification code receiver.

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

### onAuthorization(AuthorizationCodeRequestUrl authorizationUrl)

    protected void onAuthorization(AuthorizationCodeRequestUrl authorizationUrl)

Handles user authorization by redirecting to the OAuth 2.0 authorization server.

Default implementation is to call `browse(authorizationUrl.build())`. Subclasses may
override to provide optional parameters such as the recommended state parameter. Sample
implementation:

@Override
protected void onAuthorization(AuthorizationCodeRequestUrl authorizationUrl) throws IOException {
authorizationUrl.setState("xyz");
super.onAuthorization(authorizationUrl);
}

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `authorizationUrl` | `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl` authorization URL |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | I/O exception |