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

    public class IdTokenResponse extends TokenResponse

Beta   

OAuth ID Connect JSON model for a successful access token response as specified in [OpenID Connect Basic Client
Profile 1.0 (draft 23)](http://openid.net/specs/openid-connect-basic-1_0-23.html).

Implementation is not thread-safe. Sample usage:


     static JsonWebSignature executeIdToken(TokenRequest tokenRequest) throws IOException {
     IdTokenResponse idTokenResponse = IdTokenResponse.execute(tokenRequest);
     return idTokenResponse.parseIdToken();
     }
     
## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> java.util.AbstractMap \> com.google.api.client.util.GenericData \> com.google.api.client.json.GenericJson \> [TokenResponse](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse) \> IdTokenResponse

## Inherited Members

[TokenResponse.clone()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_clone__) [TokenResponse.getAccessToken()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_getAccessToken__) [TokenResponse.getExpiresInSeconds()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_getExpiresInSeconds__) [TokenResponse.getRefreshToken()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_getRefreshToken__) [TokenResponse.getScope()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_getScope__) [TokenResponse.getTokenType()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_getTokenType__) [TokenResponse.set(String,Object)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_set_java_lang_String_java_lang_Object_) [TokenResponse.setAccessToken(String)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_setAccessToken_java_lang_String_) [TokenResponse.setExpiresInSeconds(Long)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_setExpiresInSeconds_java_lang_Long_) [TokenResponse.setRefreshToken(String)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_setRefreshToken_java_lang_String_) [TokenResponse.setScope(String)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_setScope_java_lang_String_) [TokenResponse.setTokenType(String)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_setTokenType_java_lang_String_) com.google.api.client.json.GenericJson.getFactory() com.google.api.client.json.GenericJson.setFactory(com.google.api.client.json.JsonFactory) com.google.api.client.json.GenericJson.toPrettyString() com.google.api.client.json.GenericJson.toString() com.google.api.client.util.GenericData.entrySet() com.google.api.client.util.GenericData.equals(java.lang.Object) com.google.api.client.util.GenericData.get(java.lang.Object) com.google.api.client.util.GenericData.getClassInfo() com.google.api.client.util.GenericData.getUnknownKeys() com.google.api.client.util.GenericData.hashCode() com.google.api.client.util.GenericData.put(java.lang.String,java.lang.Object) com.google.api.client.util.GenericData.putAll(java.util.Map\<? extends java.lang.String,?\>) com.google.api.client.util.GenericData.remove(java.lang.Object) com.google.api.client.util.GenericData.setUnknownKeys(java.util.Map\<java.lang.String,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.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.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-) [AbstractMap.clear()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#clear--) [AbstractMap.containsKey(Object)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#containsKey-java.lang.Object-) [AbstractMap.containsValue(Object)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#containsValue-java.lang.Object-) [AbstractMap.isEmpty()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#isEmpty--) [AbstractMap.keySet()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#keySet--) [AbstractMap.put(K,V)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#put-K-V-) [AbstractMap.putAll(Map\<? extends K,? extends V\>)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#putAll-java.util.Map<? extends K-? extends V>-) [AbstractMap.size()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#size--) [AbstractMap.values()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#values--)

## Static Methods

### execute(TokenRequest tokenRequest)

    public static IdTokenResponse execute(TokenRequest tokenRequest)

Executes the given ID token request, and returns the parsed ID token response.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `tokenRequest` | `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenRequest` token request |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdTokenResponse` | parsed successful ID token response |

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

## Constructors

### IdTokenResponse()

    public IdTokenResponse()

## Methods

### clone()

    public IdTokenResponse clone()

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

**Overrides** [TokenResponse.clone()](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_clone__)

### getIdToken()

    public final String getIdToken()

Returns the ID token.

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

### parseIdToken()

    public IdToken parseIdToken()

Parses using [JsonWebSignature#parse(JsonFactory, String)](https://cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.webtoken.JsonWebSignature.html#com_google_api_client_json_webtoken_JsonWebSignature_parse_) based on the JSON factory and [ID token](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdTokenResponse#com_google_api_client_auth_openidconnect_IdTokenResponse_getIdToken__).

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

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

### set(String fieldName, Object value)

    public IdTokenResponse set(String fieldName, Object value)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `fieldName` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

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

**Overrides** [TokenResponse.set(String fieldName, Object value)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_set_java_lang_String_java_lang_Object_)

### setAccessToken(String accessToken)

    public IdTokenResponse setAccessToken(String accessToken)

Sets the access token issued by the authorization server.

Overriding is only supported for the purpose of calling the super implementation and
changing the return type, but nothing else.

| **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.openidconnect.IdTokenResponse` |   |

**Overrides** [TokenResponse.setAccessToken(String accessToken)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_setAccessToken_java_lang_String_)

### setExpiresInSeconds(Long expiresIn)

    public IdTokenResponse setExpiresInSeconds(Long expiresIn)

Sets the lifetime in seconds of the access token (for example 3600 for an hour) or `null`
for none.

Overriding is only supported for the purpose of calling the super implementation and
changing the return type, but nothing else.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `expiresIn` | `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.openidconnect.IdTokenResponse` |   |

**Overrides** [TokenResponse.setExpiresInSeconds(Long expiresInSeconds)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_setExpiresInSeconds_java_lang_Long_)

### setIdToken(String idToken)

    public IdTokenResponse setIdToken(String idToken)

Sets the ID token.

Overriding is only supported for the purpose of calling the super implementation and
changing the return type, but nothing else.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `idToken` | `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.openidconnect.IdTokenResponse` |   |

### setRefreshToken(String refreshToken)

    public IdTokenResponse setRefreshToken(String refreshToken)

Sets the refresh token which can be used to obtain new access tokens using the same
authorization grant or `null` for none.

Overriding is only supported for the purpose of calling the super implementation and
changing the return type, but nothing else.

| **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.openidconnect.IdTokenResponse` |   |

**Overrides** [TokenResponse.setRefreshToken(String refreshToken)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_setRefreshToken_java_lang_String_)

### setScope(String scope)

    public IdTokenResponse setScope(String scope)

Sets the scope of the access token or `null` for none.

Overriding is only supported for the purpose of calling the super implementation and
changing the return type, but nothing else.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `scope` | `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.openidconnect.IdTokenResponse` |   |

**Overrides** [TokenResponse.setScope(String scope)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_setScope_java_lang_String_)

### setTokenType(String tokenType)

    public IdTokenResponse setTokenType(String tokenType)

Sets the token type (as specified in [Access Token Types](http://tools.ietf.org/html/rfc6749#section-7.1)).

Overriding is only supported for the purpose of calling the super implementation and
changing the return type, but nothing else.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `tokenType` | `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.openidconnect.IdTokenResponse` |   |

**Overrides** [TokenResponse.setTokenType(String tokenType)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenResponse#com_google_api_client_auth_oauth2_TokenResponse_setTokenType_java_lang_String_)