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 ComputeCredential extends Credential
```
Beta   

Google Compute Engine service accounts OAuth 2.0 credential based on [Authenticating from Google Compute
Engine](https://developers.google.com/compute/docs/authentication).

Sample usage:

```java

 public static HttpRequestFactory createRequestFactory(
     HttpTransport transport, JsonFactory jsonFactory) {
   return transport.createRequestFactory(
     new GoogleComputeCredential(transport, jsonFactory));
 }
 
```

Implementation is immutable and thread-safe.

## Inheritance

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

## Inherited Members

com.google.api.client.auth.oauth2.Credential.executeRefreshToken() 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() com.google.api.client.auth.oauth2.Credential.setAccessToken(java.lang.String) com.google.api.client.auth.oauth2.Credential.setExpirationTimeMilliseconds(java.lang.Long) com.google.api.client.auth.oauth2.Credential.setExpiresInSeconds(java.lang.Long) com.google.api.client.auth.oauth2.Credential.setFromTokenResponse(com.google.api.client.auth.oauth2.TokenResponse) com.google.api.client.auth.oauth2.Credential.setRefreshToken(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-)

## Static Fields

### TOKEN_SERVER_ENCODED_URL

```java
public static final String TOKEN_SERVER_ENCODED_URL
```
Metadata Service Account token server encoded URL.

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

## Constructors

### ComputeCredential(ComputeCredential.Builder builder)

```java
protected ComputeCredential(ComputeCredential.Builder builder)
```

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

### ComputeCredential(HttpTransport transport, JsonFactory jsonFactory)

```java
public ComputeCredential(HttpTransport transport, JsonFactory jsonFactory)
```

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `transport` | `com.google.api.client.http.HttpTransport` HTTP transport |
| `jsonFactory` | `com.google.api.client.json.JsonFactory` JSON factory |

## Methods

### executeRefreshToken()

```java
protected TokenResponse executeRefreshToken()
```

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `com.google.api.client.auth.oauth2.TokenResponse` |   |

**Overrides** com.google.api.client.auth.oauth2.Credential.executeRefreshToken()

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `IOException` |   |