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

    public interface CredentialStore

**Deprecated.** *(to be removed in the future) Use DataStoreFactory with [StoredCredential](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.StoredCredential) instead.*

Beta   

OAuth 2.0 credential persistence store interface to provide a fully pluggable storage mechanism.

The user ID should be used as the primary key for storage, and the rest of the data consists
of the [access token](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential#com_google_api_client_auth_oauth2_Credential_getAccessToken_), refresh token, and [expiration time](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential#com_google_api_client_auth_oauth2_Credential_getExpirationTimeMilliseconds_).

Implementations should be thread safe.

## Methods

### delete(String userId, Credential credential) (deprecated)

    public abstract void delete(String userId, Credential credential)

Deletes the credential of the given user ID.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `userId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` user ID whose credential needs to be deleted |
| `credential` | `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential` credential to be deleted |

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

### load(String userId, Credential credential) (deprecated)

    public abstract boolean load(String userId, Credential credential)

Loads the credential for the given user ID.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `userId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` user ID whose credential needs to be loaded |
| `credential` | `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential` credential whose [access token](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential#com_google_api_client_auth_oauth2_Credential_setAccessToken_), [refresh token](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential#com_google_api_client_auth_oauth2_Credential_setRefreshToken_), and [expiration time](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential#com_google_api_client_auth_oauth2_Credential_setExpirationTimeMilliseconds_) need to be set if the credential already exists in storage |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` | `true` if the credential has been successfully found and loaded or `false` otherwise |

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

### store(String userId, Credential credential) (deprecated)

    public abstract void store(String userId, Credential credential)

Stores the credential of the given user ID.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `userId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` user ID whose credential needs to be stored |
| `credential` | `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential` credential whose [access token](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential#com_google_api_client_auth_oauth2_Credential_getAccessToken_), [refresh token](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential#com_google_api_client_auth_oauth2_Credential_getRefreshToken_), and [expiration time](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.Credential#com_google_api_client_auth_oauth2_Credential_getExpirationTimeMilliseconds_) need to be stored |

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