title: How to get Openshift session token using rest api calls
body: <p>As part of an automated tests suite I have to use OpenShift's REST APIs to send commands and get OpenShift's status. To authenticate these API calls I need to embed an authorization token in every call. </p>
  
  <p>Currently, I get this token by executing the following commands with ssh on the machine where OpenShift is installed: 
  <code>
  oc login --username=&lt;uname&gt; --password=&lt;password&gt;
  oc whoami --show-token
  </code></p>
  
  <p>I would like to stop using the <strong>oc</strong> tool completely and get this token using HTTP calls to the APIs but am not really able to find a document that explains how to use it. If I use the option <code>--loglevel=10</code> when calling oc commands I can see the HTTP calls made by <code>oc</code> when logging in but it is quite difficult for me to reverse-engineer the process from these logs. </p>
  
  <p>Theoretically this is not something specific to OpenShift but rather to the OAuth protocol, I have found some documentation like the one posted <a href="https://auth0.com/docs/api-auth/grant/implicit" rel="noreferrer">here</a> but I still find it difficult to implement without specific examples. </p>
  
  <p>If that helps, I am developing this tool using ruby (not rails). </p>
  
  <p>P.S. I know that normally for this type of job one should use Service Account Tokens but since this is a testing environment the OpenShift installation gets removed and reinstalled fairly often. This would force me to re-create the service account every time with the oc command line tool and again prevent me from automatizing the process. </p>