1
0
forked from docs/doc-exports
doc-exports/docs/css/api-ref/css_03_0139.html
Zheng, Xiu 3fa966049f css api 20240704 version
Reviewed-by: Kacur, Michal <michal.kacur@t-systems.com>
Co-authored-by: Zheng, Xiu <zhengxiu@huawei.com>
Co-committed-by: Zheng, Xiu <zhengxiu@huawei.com>
2024-07-22 17:01:37 +00:00

44 lines
2.9 KiB
HTML

<a name="css_03_0139"></a><a name="css_03_0139"></a>
<h1 class="topictitle1">Authentication</h1>
<div id="body8662426"><p id="css_03_0139__en-us_topic_0170917208_en-us_topic_0168405764_p26613555143846">CSS supports token authentication.</p>
<div class="section" id="css_03_0139__en-us_topic_0170917208_section34951335121613"><h4 class="sectiontitle">Authentication Using Tokens</h4><div class="note" id="css_03_0139__en-us_topic_0170917208_note1449573531616"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="css_03_0139__en-us_topic_0170917208_p1849553514166">The validity period of a token is 24 hours. When using a token for authentication, cache it to prevent frequently calling the IAM API.</p>
</div></div>
<p id="css_03_0139__en-us_topic_0170917208_p11495135111617">A token specifies certain permissions in a computer system. Authentication using a token adds the token to a request as its header during API calling to obtain permissions to operate APIs through IAM.</p>
<p id="css_03_0139__en-us_topic_0170917208_p4938113918117">The API for obtaining a token is <strong id="css_03_0139__b13479185920382">POST https://</strong><em id="css_03_0139__i1697042173911">{IAM endpoint}</em><strong id="css_03_0139__b924711573913">/v3/auth/tokens</strong>. For details about how to obtain IAM endpoints, see <a href="css_03_0053.html">Endpoints</a>.</p>
<pre class="screen" id="css_03_0139__en-us_topic_0170917208_screen84049561000">{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": "username", //Username
"password": "********", //Login password
"domain": {
"name": "domainname" //Name of the account that the user belongs to
}
}
}
},
"scope": {
"project": {
"name": "xxxxxxxx" //Project name
}
}
}
}</pre>
<p id="css_03_0139__en-us_topic_0170917208_p175512042712">After a token is obtained, the <strong id="css_03_0139__en-us_topic_0170917208_b4962111369581">X-Auth-Token</strong> header field must be added to requests to specify the token when calling other APIs. For example, if the token is <strong id="css_03_0139__en-us_topic_0170917208_b9389950329581">ABCDEFJ....</strong>, <strong id="css_03_0139__en-us_topic_0170917208_b18594742059581">X-Auth-Token: ABCDEFJ....</strong> can be added to a request as follows:</p>
<pre class="screen" id="css_03_0139__en-us_topic_0170917208_en-us_topic_0170917208_en-us_topic_0168405764_screen11189101154015">POST https://{endpoint}/v3/auth/projects
Content-Type: application/json
<strong id="css_03_0139__en-us_topic_0170917208_en-us_topic_0170917208_en-us_topic_0168405764_b172853338430">X-Auth-Token: ABCDEFJ....</strong></pre>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="css_03_0137.html">Calling APIs</a></div>
</div>
</div>