OpenShift - Display user name and token using the oc whoami 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.

The oc whoami command without any options or flags will simply display your username, like this.

~]# oc whoami
john.doe

 

The -h or --help flag can be used to display the options or flags that can be used.

~]# oc whoami --help
Show information about the current session 

The default options for this command will return the currently authenticated user name or an empty string.  Other flags
support returning the currently used token or the user context.

Usage:
  oc whoami [flags]

Options:
  -c, --show-context=false: Print the current user context name
      --show-server=false: If true, print the current server's REST API URL
  -t, --show-token=false: Print the token the current session is using. This will return an error if you are using a
different form of authentication.

Use "oc options" for a list of global command-line options (applies to all commands).

 

The -t or --show-token=true option can be used to display the users token.

~]# oc whoami -t
k8QzC9ZVo9Up7Ov2jn2Qm1bexp77Zy_haKrLdp0t1FR

 




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 95d50 in the box below so that we can be sure you are a human.