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

    public final class StoredCredential implements Serializable

Beta   

Credential information to be stored in a DataStoreFactory.

Implementation is thread safe.

## Inheritance

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

## Implements

[Serializable](https://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html)

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

### DEFAULT_DATA_STORE_ID

    public static final String DEFAULT_DATA_STORE_ID

Default data store ID.

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

## Static Methods

### getDefaultDataStore(DataStoreFactory dataStoreFactory)

    public static DataStore<StoredCredential> getDefaultDataStore(DataStoreFactory dataStoreFactory)

Returns the stored credential data store using the ID [#DEFAULT_DATA_STORE_ID](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.StoredCredential#com_google_api_client_auth_oauth2_StoredCredential_DEFAULT_DATA_STORE_ID).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `dataStoreFactory` | `com.google.api.client.util.store.DataStoreFactory` data store factory |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.api.client.util.store.DataStore<https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.StoredCredential>` | stored credential data store |

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

## Constructors

### StoredCredential()

    public StoredCredential()

### StoredCredential(Credential credential)

    public StoredCredential(Credential credential)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `credential` | `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential` existing credential to copy from |

## Methods

### equals(Object other)

    public boolean equals(Object other)

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

**Overrides** [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-)

### getAccessToken()

    public String getAccessToken()

Returns the access token or `null` for none.

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

### getExpirationTimeMilliseconds()

    public Long getExpirationTimeMilliseconds()

Returns the expected expiration time in milliseconds or `null` for none.

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

### getRefreshToken()

    public String getRefreshToken()

Returns the refresh token or `null` for none.

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

### hashCode()

    public int hashCode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

**Overrides** [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--)

### setAccessToken(String accessToken)

    public StoredCredential setAccessToken(String accessToken)

Sets the access token or `null` for none.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `accessToken` | `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.StoredCredential` |   |

### setExpirationTimeMilliseconds(Long expirationTimeMilliseconds)

    public StoredCredential setExpirationTimeMilliseconds(Long expirationTimeMilliseconds)

Sets the expected expiration time in milliseconds or `null` for none.

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

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

### setRefreshToken(String refreshToken)

    public StoredCredential setRefreshToken(String refreshToken)

Sets the refresh token or `null` for none.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `refreshToken` | `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.StoredCredential` |   |

### toString()

    public String toString()

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

**Overrides** [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)