2.9.1 (latest) 2.9.0 2.8.1 2.7.2 2.6.0 2.5.1 2.4.1 2.1.2 2.0.1 1.35.2 1.34.1 1.33.4

    public class GoogleAuthorizationCodeFlow extends AuthorizationCodeFlow

Thread-safe Google OAuth 2.0 authorization code flow that manages and persists end-user
credentials.

This is designed to simplify the flow in which an end-user authorizes the application to
access their protected data, and then the application has access to their data based on an access
token and a refresh token to refresh that access token when it expires.

The first step is to call #loadCredential(String) based on the known user ID to check
if the end-user's credentials are already known. If not, call [#newAuthorizationUrl()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow#com_google_api_client_googleapis_auth_oauth2_GoogleAuthorizationCodeFlow_newAuthorizationUrl__) and
direct the end-user's browser to an authorization page. The web browser will then redirect to the
redirect URL with a `"code"` query parameter which can then be used to request an access
token using [#newTokenRequest(String)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow#com_google_api_client_googleapis_auth_oauth2_GoogleAuthorizationCodeFlow_newTokenRequest_java_lang_String_). Finally, use #createAndStoreCredential(TokenResponse, String) to store and obtain a credential for accessing
protected resources.

The default for the `approval_prompt` and `access_type` parameters is `
null`. For web applications that means `"approval_prompt=auto&access_type=online"` and for
installed applications that means `"approval_prompt=force&access_type=offline"`. To
override the default, you need to explicitly call Builder#setApprovalPrompt(String) and
Builder#setAccessType(String).

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> com.google.api.client.auth.oauth2.AuthorizationCodeFlow \> GoogleAuthorizationCodeFlow

## Inherited Members

com.google.api.client.auth.oauth2.AuthorizationCodeFlow.createAndStoreCredential(com.google.api.client.auth.oauth2.TokenResponse,java.lang.String) com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getAuthorizationServerEncodedUrl() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getClientAuthentication() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getClientId() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getClock() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getCredentialDataStore() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getCredentialStore() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getJsonFactory() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getMethod() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getRefreshListeners() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getRequestInitializer() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getScopes() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getScopesAsString() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getTokenServerEncodedUrl() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.getTransport() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.loadCredential(java.lang.String) com.google.api.client.auth.oauth2.AuthorizationCodeFlow.newAuthorizationUrl() com.google.api.client.auth.oauth2.AuthorizationCodeFlow.newTokenRequest(java.lang.String) [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-)

## Constructors

### GoogleAuthorizationCodeFlow(GoogleAuthorizationCodeFlow.Builder builder)

    protected GoogleAuthorizationCodeFlow(GoogleAuthorizationCodeFlow.Builder builder)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `builder` | `https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow.Builder` Google authorization code flow builder |

### GoogleAuthorizationCodeFlow(HttpTransport transport, JsonFactory jsonFactory, String clientId, String clientSecret, Collection\<String\> scopes)

    public GoogleAuthorizationCodeFlow(HttpTransport transport, JsonFactory jsonFactory, String clientId, String clientSecret, Collection<String> scopes)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `transport` | `com.google.api.client.http.HttpTransport` HTTP transport |
| `jsonFactory` | `com.google.api.client.json.JsonFactory` JSON factory |
| `clientId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` client identifier |
| `clientSecret` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` client secret |
| `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>` collection of scopes to be joined by a space separator |

## Methods

### getAccessType()

    public final String getAccessType()

Returns the access type (`"online"` to request online access or `"offline"` to
request offline access) or `null` for the default behavior of `"online"`.

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

### getApprovalPrompt()

    public final String getApprovalPrompt()

Returns the approval prompt behavior (`"auto"` to request auto-approval or `
"force"` to force the approval UI to show) or `null` for the default behavior of `
"auto"`.

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

### newAuthorizationUrl()

    public GoogleAuthorizationCodeRequestUrl newAuthorizationUrl()

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

**Overrides** com.google.api.client.auth.oauth2.AuthorizationCodeFlow.newAuthorizationUrl()

### newTokenRequest(String authorizationCode)

    public GoogleAuthorizationCodeTokenRequest newTokenRequest(String authorizationCode)

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

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

**Overrides** com.google.api.client.auth.oauth2.AuthorizationCodeFlow.newTokenRequest(java.lang.String)