<p><a href="https://i.stack.imgur.com/aWsNv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aWsNv.png" alt="enter image description here"></a></p>

<p>Please refer to the above image, I am trying to access Kubernetes Clusters Using the Kubernetes API and for that purpose as mentioned in <a href="https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/" rel="nofollow noreferrer">documents</a> I am using Python Kuberentes Client, that needs a token to communicate with <code>Kube API</code>.</p>

<p>When I am trying to authenticate the user with the token added in <code>Kube-config</code> file by Kube login everything works fine, where token provided by <code>Keycloak</code> REST API results in an un-authorization error.</p>

<p>I would be glad if anyone could provide any insight on this issue.</p>

<p>We have resolved the issue, below are our findings and their resolution:</p>

<ul>
<li>There was a discrepancy in the token generated with KubeLogin client 
and Keycloak Rest API, issuer URL is hostname in the token generated with KubeLogin whereas in the token generated with Keycloak Rest API 
issuer URL is IP Address.</li>
<li>Also, In our(Keycloak instance) generated certificate, we have
   hostname as issuer name which might be the reason for getting un-authorization errors. We reconfigured the Keycloak with new certificates which have DNS name.</li>
<li>We had to create RBAC with cluster scope.</li>
</ul>
