OpenShift - Display users token using the oc config view command

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

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





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




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |