<p>In kubernetes, every serviceaccount has a corresponding secret which hold a token.How can I get the serviceaccount' Info(ex. name and namespace) through the token?</p>

zhixin.cao
<p>The SA secret token is based on JWT
you can use for example: <a href="https://www.jsonwebtoken.io/" rel="nofollow noreferrer">https://www.jsonwebtoken.io/</a> to get a json containing the information of the token as follow:</p>

<pre><code>{
 "iss": "kubernetes/serviceaccount",
 "kubernetes.io/serviceaccount/namespace": "**&lt;your_namespace&gt;**",
 "kubernetes.io/serviceaccount/secret.name": "**&lt;your_sa_name&gt;-token-xxxxx**",
 "kubernetes.io/serviceaccount/service-account.name": "**&lt;your_sa_name&gt;**",
 "kubernetes.io/serviceaccount/service-account.uid": "**&lt;your_sa_uid&gt;**",
 "sub": "system:serviceaccount:&lt;your_namespace&gt;:**&lt;your_sa_name&gt;**",
 "jti": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
 "iat": 9999999999,
 "exp": 9999999999
}
</code></pre>

<p>Hope this helps</p>
