Bootstrap FreeKB - OpenShift - Display users token using the oc config view command
OpenShift - Display users token using the oc config view command

Updated:   |  OpenShift articles

If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.

The following options can be used to display a users token.

  • In the users /home/your_username/.kube/config file | using the oc config view command (this article)
  • Using the whoami --show-token=true command

After you have successfully logged into OpenShift, your /home/your_username/.kube/config file will be updated.

~]$ oc config view
apiVersion: v1
clusters:
- cluster:
    server: https://api.openshift.example.com:6443
contexts:
- context:
    cluster: api-openshift-example-com:6443
    namespace: default
    user: john.doe/api-openshift-example-com:6443
  name: default/api-openshift-example-com:6443/john.doe
current-context: default/api-openshift-example-com:6443/john.doe
kind: Config
preferences: {}
users:
- name: john.doe
  user:
    token: sha256~83miYt8vIEHeP6CDaTKRy2SUruoo-TuVxdYToGQQOqo

 

The oc config view command can be used to parse your /home/your_username/.kube/config file and display the contents of the file, which should return something like this. Noticed that token has REDACTED.

~]$ oc config view
apiVersion: v1
clusters:
- cluster:
    server: https://api.openshift.example.com:6443
contexts:
- context:
    cluster: api-openshift-example-com:6443
    namespace: default
    user: john.doe/api-openshift-example-com:6443
  name: default/api-openshift-example-com:6443/john.doe
current-context: default/api-openshift-example-com:6443/john.doe
kind: Config
preferences: {}
users:
- name: john.doe
  user:
    token: REDACTED

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 13c44c in the box below so that we can be sure you are a human.