2.9.3 (latest) 2.9.2 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

```java
public class MockGoogleCredential extends GoogleCredential
```
Beta   

Mock for [GoogleCredential](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt).

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> com.google.api.client.auth.oauth2.Credential \> [GoogleCredential](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt) \> MockGoogleCredential

## Inherited Members

com.google.api.client.auth.oauth2.Credential.getAccessToken() com.google.api.client.auth.oauth2.Credential.getClientAuthentication() com.google.api.client.auth.oauth2.Credential.getClock() com.google.api.client.auth.oauth2.Credential.getExpirationTimeMilliseconds() com.google.api.client.auth.oauth2.Credential.getExpiresInSeconds() com.google.api.client.auth.oauth2.Credential.getJsonFactory() com.google.api.client.auth.oauth2.Credential.getMethod() com.google.api.client.auth.oauth2.Credential.getRefreshListeners() com.google.api.client.auth.oauth2.Credential.getRefreshToken() com.google.api.client.auth.oauth2.Credential.getRequestInitializer() com.google.api.client.auth.oauth2.Credential.getTokenServerEncodedUrl() com.google.api.client.auth.oauth2.Credential.getTransport() com.google.api.client.auth.oauth2.Credential.handleResponse(com.google.api.client.http.HttpRequest,com.google.api.client.http.HttpResponse,boolean) com.google.api.client.auth.oauth2.Credential.initialize(com.google.api.client.http.HttpRequest) com.google.api.client.auth.oauth2.Credential.intercept(com.google.api.client.http.HttpRequest) com.google.api.client.auth.oauth2.Credential.refreshToken() [GoogleCredential.createDelegated(String)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_createDelegated_java_lang_String_) [GoogleCredential.createScoped(Collection\<String\>)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_createScoped_java_util_Collection_java_lang_String__) [GoogleCredential.createScopedRequired()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_createScopedRequired__) [GoogleCredential.executeRefreshToken()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_executeRefreshToken__) [GoogleCredential.fromStream(InputStream)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_fromStream_java_io_InputStream_) [GoogleCredential.fromStream(InputStream,HttpTransport,JsonFactory)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_fromStream_java_io_InputStream_com_google_api_client_http_HttpTransport_com_google_api_client_json_JsonFactory_) [GoogleCredential.getApplicationDefault()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_getApplicationDefault__) [GoogleCredential.getApplicationDefault(HttpTransport,JsonFactory)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_getApplicationDefault_com_google_api_client_http_HttpTransport_com_google_api_client_json_JsonFactory_) [GoogleCredential.getServiceAccountId()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_getServiceAccountId__) [GoogleCredential.getServiceAccountPrivateKey()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_getServiceAccountPrivateKey__) [GoogleCredential.getServiceAccountPrivateKeyId()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_getServiceAccountPrivateKeyId__) [GoogleCredential.getServiceAccountProjectId()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_getServiceAccountProjectId__) [GoogleCredential.getServiceAccountScopes()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_getServiceAccountScopes__) [GoogleCredential.getServiceAccountScopesAsString()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_getServiceAccountScopesAsString__) [GoogleCredential.getServiceAccountUser()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_getServiceAccountUser__) [GoogleCredential.setAccessToken(String)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_setAccessToken_java_lang_String_) [GoogleCredential.setExpirationTimeMilliseconds(Long)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_setExpirationTimeMilliseconds_java_lang_Long_) [GoogleCredential.setExpiresInSeconds(Long)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_setExpiresInSeconds_java_lang_Long_) [GoogleCredential.setFromTokenResponse(TokenResponse)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_setFromTokenResponse_com_google_api_client_auth_oauth2_TokenResponse_) [GoogleCredential.setRefreshToken(String)](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_setRefreshToken_java_lang_String_) [GoogleCredential.toBuilder()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_toBuilder__) [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

### ACCESS_TOKEN

```java
public static final String ACCESS_TOKEN
```

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `String` |   |

### REFRESH_TOKEN

```java
public static final String REFRESH_TOKEN
```

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `String` |   |

## Static Methods

### newMockHttpTransportWithSampleTokenResponse()

```java
public static MockHttpTransport newMockHttpTransportWithSampleTokenResponse()
```
Returns a new MockHttpTransport with a sample MockLowLevelHttpResponse. The
response includes sample TokenResponse content as specified in DEFAULT_TOKEN_RESPONSE_JSON.
This is meant to produce a minimal implementation that allows methods such as [GoogleCredential#executeRefreshToken()](https://docs.cloud.google.com/java/docs/reference/google-api-client/latest/com.google.api.client.googleapis.auth.oauth2.GoogleCredential.md.txt#com_google_api_client_googleapis_auth_oauth2_GoogleCredential_executeRefreshToken__) to be called without failing abruptly. This content is
static. If you are making assertions based on the content of the request, then
MockTokenServerTransport should be used instead.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.api.client.testing.http.MockHttpTransport` | mockHttpTransport |

## Constructors

### MockGoogleCredential(MockGoogleCredential.Builder builder)

```java
public MockGoogleCredential(MockGoogleCredential.Builder builder)
```

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `builder` | `MockGoogleCredential.Builder` |