<button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">Version 1.13 </button>

- [Latest](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/latest/troubleshooting/troubleshoot-oidc)
- [Version 1.16](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/1.16/troubleshooting/troubleshoot-oidc)
- [Earlier versions (unsupported)](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/1.13/getting-support.md.txt#version-support)

<br />

This page shows you how to identify and resolve OpenID Connect (OIDC) issues
with Google Distributed Cloud.

## Identify OIDC issues

When OIDC is not working for Google Distributed Cloud, typically the OIDC
specification within the cluster config file has been improperly configured.
This section provides instructions for reviewing logs and the OIDC specification
to help identify the cause of an OIDC problem.

### Review the GKE Identity Service logs

GKE Identity Service supports OIDC in Google Distributed Cloud.

1. Use `kubectl logs` to print the GKE Identity Service logs:

   ```bash
   kubectl --kubeconfig CLUSTER_KUBECONFIG -n anthos-identity-service logs \
   deployment/ais --all-containers=true
   ```
2. Review the logs for errors that can help you diagnose OIDC problems.

   If you are unable to authenticate with OIDC, GKE Identity Service logs
   provide the most relevant and useful information for debugging the problem.

   For example, if the OIDC specification (in the cluster config file) has a
   typo in the `issuerURL` field, such as `htps://accounts.google.com` (missing
   a "t" in https), the GKE Identity Service logs will contain an entry
   like this:

       OIDC (htps://accounts.google.com) - Unable to fetch JWKs needed to validate OIDC ID token.

3. If you have identified a configuration issue in the logs, proceed to
   [Reconfiguring OIDC](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/1.13/troubleshooting/troubleshoot-oidc.md.txt#reconfiguring_oidc).

4. If you are unable to diagnose and resolve the problem yourself, [engage with
   Cloud Customer Care](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/1.13/getting-support).

   Cloud Customer Care will need the GKE Identity Service logs and the [OIDC
   specification](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/1.13/troubleshooting/troubleshoot-oidc#checking_the_oidc_specification_in_your_cluster) to diagnose
   and resolve OIDC problems.

### Check the OIDC specification in your cluster

The OIDC information for your cluster is specified in the `clientconfig` object
in the `kube-public` namespace.

1. Use `kubectl get` to print the OIDC resource for your cluster:

   ```bash
   kubectl --kubeconfig CLUSTER_KUBECONFIG -n kube-public get \
   clientconfig.authentication.gke.io default -o yaml
   ```

   > [!NOTE]
   > **Note:** The `clientconfig` spec may differ slightly from the OIDC spec in your cluster config file. For example, the OIDC provider URL is specified with the `issuerURL` field in the cluster config file, but the `clientconfig` object returns this information in the `issuerURI` field.

2. Review the field values to confirm the specification is configured correctly
   for your OIDC provider.

3. If you have identified a configuration issue in the specification, proceed to
   [Reconfiguring OIDC](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/1.13/troubleshooting/troubleshoot-oidc.md.txt#reconfiguring_oidc).

4. If you are unable to diagnose and resolve the problem yourself, [engage with
   Cloud Customer Care](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/1.13/getting-support).

   Cloud Customer Care will need the [GKE Identity Service
   logs](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/1.13/troubleshooting/troubleshoot-oidc#reviewing_the_logs) and the OIDC specification to diagnose and resolve
   OIDC problems.

## Reconfigure OIDC

If you identified problems in either the GKE Identity Service logs or the
the `clientconfig` object, you can reconfigure OIDC in your cluster (without
re-creating the cluster) to address them. To reconfigure OIDC, edit the KRM
default object of type `clientconfig` in the`kube-public` namespace:

```yaml
kubectl --kubeconfig CLUSTER_KUBECONFIG -n kube-public edit clientconfig default
```

Details from the ClientConfig CRD are used to configure OIDC for both
the Google Cloud console and the Authentication plugin for GKE Enterprise. For details about the OIDC
Information included in the ClientConfig CRD, see the following YAML and
associated table of field descriptions.

> [!NOTE]
> **Note:** Some field names in this CRD may differ slightly from the field names used in the OIDC specification in the cluster configuration file for Google Distributed Cloud. For example, `issuerURI` versus `issuerURL`.

```yaml
authentication:
  - name: oidc
    oidc:
      certificateAuthorityData: CERTIFICATE_STRING
      clientID: CLIENT_ID
      clientSecret: CLIENT_SECRET
      cloudConsoleRedirectURI: "http://console.cloud.google.com/kubernetes/oidc"
      deployCloudConsoleProxy: PROXY_BOOLEAN
      extraParams: EXTRA_PARAMS
      groupsClaim: GROUPS_CLAIM
      groupPrefix: GROUP_PREFIX
      issuerURI: ISSUER_URI
      kubectlRedirectURI: KUBECTL_REDIRECT_URI
      scopes: SCOPES
      userClaim: USER_CLAIM
      userPrefix: USER_PREFIX
    proxy: PROXY_URL
```

The following table describes the fields of the ClientConfig CRD `oidc` object.

| Field | Required | Description | Format |
|---|---|---|---|
| name | Yes | The name of the OIDC configuration to create. | String |
| certificateAuthorityData | No | A `base64`-encoded [PEM-encoded certificate](https://wikipedia.org/wiki/Privacy-Enhanced_Mail) for the OIDC provider. To create the string, encode the certificate, including headers, into `base64`. Include the resulting string in `certificateAuthorityData` as a single line. Example: `certificateAuthorityData: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tC...k1JSUN2RENDQWFT==` | String |
| clientID | Yes | ID for the client application that makes authentication requests to the OpenID provider. | String |
| clientSecret | No | Shared secret between the OIDC client application and the OIDC provider. | String |
| extraParams | No | Additional key-value parameters to send to the OpenID provider. If you are authorizing a group, pass in `resource=token-groups-claim`. If your authorization server prompts for consent for authentication with Microsoft Azure and Okta, set `extraParams` to `prompt=consent`. For Cloud Identity, set `extraParams` to `prompt=consent,access_type=offline`. | Comma-delimited list |
| groupsClaim | No | [JWT](https://tools.ietf.org/html/rfc7519) claim that the provider uses to return your security groups. | String |
| groupPrefix | No | Prefix prepended to group claims to prevent clashes with existing names. For example, if you have two groups named `foobar`, add a prefix `gid-`. The resulting group is `gid-foobar`. | String |
| issuerURI | Yes | URL where authorization requests are sent to your OpenID, such as `https://example.com/adfs`. The Kubernetes API server uses this URL to discover public keys for verifying tokens. The URI must use HTTPS. | URL String |
| kubectlRedirectURI | Yes | The redirect URL that `kubectl` uses for authorization. | URL String |
| scopes | Yes | Additional scopes to send to the OpenID provider. Microsoft Azure and Okta require the `offline_access` scope. | Comma-delimited list |
| userClaim | No | JWT claim to use as the username. You can choose other claims, such as email or name, depending on the OpenID provider. However, claims other than email are prefixed with the issuer URL to prevent naming clashes. | String |
| userPrefix | No | Prefix prepended to username claims to prevent clashes with existing names. | String |
| proxy | No | Proxy server to use for the `auth` method, if applicable. For example: `` http://user:password@10.10.10.10:8888`.` `` | String |