# Rancher CLI with Keycloack AuthProvider

**URL:** <https://forums.suse.com/t/rancher-cli-with-keycloack-authprovider/40250>\
**Category:** General\
**Created:** [March 14, 2023, 3:44pm UTC](https://forums.suse.com/t/rancher-cli-with-keycloack-authprovider/40250 "2023-03-14T15:44:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rafik](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/rafik/32/9855_2.png) [@rafik](https://forums.suse.com/u/rafik)\
**Post date:** [March 14, 2023, 3:44pm UTC](https://forums.suse.com/t/rancher-cli-with-keycloack-authprovider/40250/1 "2023-03-14T15:44:49Z")

</div>

Hello everyone, hope you are doing well.

I want to use my Keycloak / Rancher realm defined users to connect my `rancher-cli` to my Rancher.  
When trying to generate the token and `.rancher/cli2.json`, I have the following error:

Client side (rancher-cli)

```bash
% rancher token --user testuser --auth-provider keyCloakOIDCProvider --server https://myrancher.com                                                          
Enter credentials for keyCloakOIDCProvider 
 
Enter username: testuser
Enter password: 
FATA[0006] error logging in: code: [ServerError] message:[Server error while authenticating] 

```

Server side (Rancher Server)

```bash
2023/03/14 15:28:12 [ERROR] API error response 500 for POST /v3-public/keyCloakOIDCProviders/keycloakoidc?action=login. Cause: oauth2: cannot fetch token: 400 Bad Request
Response: {"error":"invalid_grant","error_description":"Code not valid"}

```

What does this error mean? Any idea ? Thank you in advance. 😊
