> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Troubleshooting authentication with external OIDC providers in Managed Service for Kubernetes®

If users can't sign in to a Managed Service for Kubernetes cluster with an external OpenID Connect (OIDC) identity provider (IdP), or you can't add or update a provider, check the causes below. For an overview of how OIDC authentication works, see [Authentication with external OIDC providers in Managed Service for Kubernetes®](https://docs.nebius.com/kubernetes/authentication/oidc-providers.md).

If no OIDC user can sign in, connect to the cluster with your Nebius AI Cloud credentials and fix the provider configuration. For instructions, see [How to configure external OIDC providers in Managed Service for Kubernetes®](https://docs.nebius.com/kubernetes/authentication/oidc-authentication.md).

## How to find the cause of an error

To see how the cluster authenticates a user, run the following command with the kubeconfig file of the user:

```bash theme={null}
kubectl auth whoami --kubeconfig=oidc.kubeconfig
```

Use the output to find the cause:

* If kubectl can't get a token from the IdP, see [Sign-in errors](#sign-in-errors).
* If the output is `error: You must be logged in to the server (Unauthorized)`, the API server rejected the token. See [Unauthorized error](#unauthorized-error).
* If the output shows the username and groups of the user, the user is authenticated. If the user still can't run commands, compare the username and groups with your role-based access control (RBAC) bindings. See [Forbidden error](#forbidden-error).

If you sign in with a kubeconfig file from your cluster administrator and can't fix the error yourself, send the administrator the error message and the output of this command.

## Configuration rejected by the cluster

The cluster checks the provider configuration before it applies it. The error message names the parameter that failed the check. Common causes:

* The cluster runs an [unrecommended Kubernetes version](https://docs.nebius.com/kubernetes/versions.md#available-kubernetes-versions).
* A prefix starts with `system:` or `nebius:`.
* Two providers have the same name or the same issuer URL.
* The issuer URL doesn't use HTTPS, contains a query or a fragment, or points to the cluster itself.
* A claim mapping has both `claim` and `expression`, or an expression mapping has a `prefix`.
* A claim validation rule has both `claim` and `expression`, an exact-match rule has a `message`, or an expression rule has a `required_value`.
* A Common Expression Language (CEL) expression doesn't compile.
* An expression uses `claims.email` without checking `email_verified`.
* `issuer.certificate_authority` isn't a valid PEM bundle.
* The cluster has more than 64 providers.

## Sign-in errors

The user can't complete the sign-in, so kubectl doesn't get a token. Check that the user is assigned to the client application in the IdP.

If users sign in with kubelogin, also check the following:

* kubelogin is installed. If it isn't, kubectl reports that the `oidc-login` command is unknown. For instructions, see [How to sign in to the cluster](https://docs.nebius.com/kubernetes/authentication/oidc-authentication.md#how-to-sign-in-to-the-cluster).
* The client application in the IdP allows the authorization code grant type and the `http://localhost:8000` redirect URI. If it doesn't, the IdP shows an error after the user signs in.
* The `--oidc-issuer-url` and `--oidc-client-id` values in the kubeconfig file match the issuer URL of the IdP and the client ID of the application.

If users sign in with a different client, check its settings according to its documentation.

## Unauthorized error

The API server rejected the token. Check the following:

* The update operation that added or changed the provider has completed.
* The issuer URL and the discovery document are publicly accessible over HTTPS.
* The `issuer` field of the discovery document matches `issuer.url` exactly, including the trailing slash. To see the document, open `<issuer_URL>/.well-known/openid-configuration` in a browser.
* The public keys of the IdP include the key that signed the token.
* The token hasn't expired.
* The `aud` claim of the token contains one of the values in `issuer.audiences`.
* The token contains the claims that the mappings use, and `email_verified` isn't `false`.
* The token passes all [validation rules](https://docs.nebius.com/kubernetes/authentication/oidc-providers.md#validation-rules).
* The mapped username and groups don't start with `system:`.

To see the claims of a token from your IdP with kubelogin, run the following command and sign in:

```bash theme={null}
kubectl oidc-login setup \
  --oidc-issuer-url=<issuer_URL> \
  --oidc-client-id=<client_ID> \
  --oidc-extra-scope=email
```

## Forbidden error

The user is authenticated but has no permission for the request. [Get the mapped username and groups of the user](#how-to-find-the-cause-of-an-error) and check the following:

* Your RBAC bindings use the same names as the output, including the prefixes. For more information, see [How to grant access with RBAC](https://docs.nebius.com/kubernetes/authentication/oidc-authentication.md#how-to-grant-access-with-rbac).
* If the output has no groups from the IdP, the ID token has no `groups` claim. Configure the IdP to add the claim. If the IdP adds it only for a separate scope, request this scope in the kubeconfig file. For more information, see [How to prepare a kubeconfig file for users](https://docs.nebius.com/kubernetes/authentication/oidc-authentication.md#how-to-prepare-a-kubeconfig-file-for-users).
