title: Extract CloudFoundry UAAC Access Token in Ansible/Shell
body: <p>Following documentation here:
  <a href="https://docs.pivotal.io/pivotalcf/1-10/customizing/ops-man-api.html" rel="nofollow noreferrer">https://docs.pivotal.io/pivotalcf/1-10/customizing/ops-man-api.html</a></p>
  
  <p>After running:</p>
  
  <pre><code>$ uaac target https://OPS-MAN-FQDN/uaa
  $ uaac token owner get [options]
  $ uaac contexts
  </code></pre>
  
  <p>I get my context with <code>access_token</code> field set (which is also stored in <code>~/.uaac.yml</code>)</p>
  
  <p>How can I programmatically extract the <code>access_token</code> from <code>uaac context</code> (and if not from the <code>~/.uaac.yml</code>) with substring tools such as awk, gawk, etc. </p>
  
  <p>I am trying to do this in ansible, but shell would work just fine. </p>
  
  <p>In case you are wondering, the output of <code>uaac context</code> in stdout is:</p>
  
  <pre><code>[2]*[https://OPS-MAN-FQDN/uaa]
    skip_ssl_validation: true
  
    [0]*[USERNAME]
        user_id: USERID
        client_id: CLIENTID
        access_token: ACCES_TOKEN
        token_type: bearer
        refresh_token: REFRESHTOKEN
        expires_in: 43199
        scope: opsman.admin scim.me opsman.user uaa.admin clients.admin
        jti: JTI VALUE
  </code></pre>