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

[OpenID Connect](http://openid.net/connect/).

## Classes

### [IdToken](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdToken)

Beta   

ID token as described in [ID Token](http://openid.net/specs/openid-connect-basic-1_0-27.html#id_token).

Use [#parse(JsonFactory, String)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdToken#com_google_api_client_auth_openidconnect_IdToken_parse_com_google_api_client_json_JsonFactory_java_lang_String_) to parse an ID token from a string. Then, use the
`verify` methods to verify the ID token as required by the specification.

Implementation is not thread-safe.

### [IdToken.Payload](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdToken.Payload)

Beta   

ID token payload.

### [IdTokenResponse](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdTokenResponse)

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();
     }
     
### [IdTokenVerifier](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdTokenVerifier)

Thread-safe ID token verifier based on [ID Token
Validation](http://openid.net/specs/openid-connect-basic-1_0-27.html#id.token.validation).

Call [#verify(IdToken)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdTokenVerifier#com_google_api_client_auth_openidconnect_IdTokenVerifier_verify_com_google_api_client_auth_openidconnect_IdToken_) to verify an ID token. This is a light-weight object, so you may
use a new instance for each configuration of expected issuer and trusted client IDs. Sample
usage:

IdTokenVerifier verifier = new IdTokenVerifier.Builder()
.setIssuer("issuer.example.com")
.setAudience(Arrays.asList("myClientId"))
.build();
...
if (!verifier.verify(idToken)) {...}

The verifier validates token signature per current OpenID Connect Spec:
<https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation> By default, method gets a
certificate from well-known location A request to certificate location is performed using com.google.api.client.http.javanet.NetHttpTransport Either or both certificate location and
transport implementation can be overridden via Builder

IdTokenVerifier verifier = new IdTokenVerifier.Builder()
.setIssuer("issuer.example.com")
.setAudience(Arrays.asList("myClientId"))
.setHttpTransportFactory(customHttpTransportFactory)
.build();
...
if (!verifier.verify(idToken)) {...}

not recommended: this check can be disabled with OAUTH_CLIENT_SKIP_SIGNATURE environment variable
set to true. Use [#verifyPayload(IdToken)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdTokenVerifier#com_google_api_client_auth_openidconnect_IdTokenVerifier_verifyPayload_com_google_api_client_auth_openidconnect_IdToken_) instead.

Note that [#verify(IdToken)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdTokenVerifier#com_google_api_client_auth_openidconnect_IdTokenVerifier_verify_com_google_api_client_auth_openidconnect_IdToken_) only implements a subset of the verification steps, mostly
just the MUST steps. Please read [ID Token
Validation](http://openid.net/specs/openid-connect-basic-1_0-27.html#id.token.validation) for the full list of verification steps.

### [IdTokenVerifier.Builder](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdTokenVerifier.Builder)

Builder for [IdTokenVerifier](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.IdTokenVerifier).

Implementation is not thread-safe.

## Interfaces

### [HttpTransportFactory](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.openidconnect.HttpTransportFactory)

A base interface for all HttpTransport factories.

Implementation must provide a public no-arg constructor. Loading of a factory implementation
is done via java.util.ServiceLoader.