doc-exports/docs/dws/api-ref/dws_02_0064.html
Lu, Huayi b974c4b77e DWS API 2022101001 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2022-12-12 18:34:53 +00:00

41 lines
3.8 KiB
HTML

<a name="EN-US_TOPIC_0000001134564658"></a><a name="EN-US_TOPIC_0000001134564658"></a>
<h1 class="topictitle1">Authentication</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001134564658__p132415792316">Calling an API can be authenticated using tokens.</p>
<div class="section" id="EN-US_TOPIC_0000001134564658__se42eaf07b9464e7b8becd7c3cb824afb"><h4 class="sectiontitle">Token-based Authentication</h4><p id="EN-US_TOPIC_0000001134564658__a5e74a303f7e7490e973e81e4d0a3e6fb">A token specifies temporary permissions in a computer system. During API authentication using a token, the token is added to request headers to get permissions for calling the API.</p>
<div class="note" id="EN-US_TOPIC_0000001134564658__note185371034218"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001134564658__p1753714319217">The validity period of a token is 24 hours. When using a token for authentication, cache it to prevent frequently calling the IAM API used to obtain a user token.</p>
</div></div>
<p id="EN-US_TOPIC_0000001134564658__p1160363317231">When calling the API to obtain a user token, you must set <strong id="EN-US_TOPIC_0000001134564658__b357314505014">auth.scope</strong> in the request body to <strong id="EN-US_TOPIC_0000001134564658__b12450131312504">project</strong>.</p>
<pre class="screen" id="EN-US_TOPIC_0000001134564658__screen1954692813282">{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": "<strong id="EN-US_TOPIC_0000001134564658__b10546152892811"><em id="EN-US_TOPIC_0000001134564658__i14546152872814">user_name</em></strong>",
"password": "<strong id="EN-US_TOPIC_0000001134564658__b55461828152819"><em id="EN-US_TOPIC_0000001134564658__i1954618287289">********</em></strong>",
"domain": {
"name": "<strong id="EN-US_TOPIC_0000001134564658__b85460281281"><em id="EN-US_TOPIC_0000001134564658__i17546162818286">domainname</em></strong>"
}
}
}
},
<strong id="EN-US_TOPIC_0000001134564658__b1419285411450"> </strong>"<strong id="EN-US_TOPIC_0000001134564658__b1473555710454">scope</strong>"<strong id="EN-US_TOPIC_0000001134564658__b17361957194516">: {</strong>
<strong id="EN-US_TOPIC_0000001134564658__b733812464"> </strong>"<strong id="EN-US_TOPIC_0000001134564658__b581717418463">project</strong>"<strong id="EN-US_TOPIC_0000001134564658__b78181842467">: {</strong>
<strong id="EN-US_TOPIC_0000001134564658__b912988164615"> </strong>"<strong id="EN-US_TOPIC_0000001134564658__b14581551151410">id</strong>"<strong id="EN-US_TOPIC_0000001134564658__b1262051515469">: </strong>"<strong id="EN-US_TOPIC_0000001134564658__b135491918462"><em id="EN-US_TOPIC_0000001134564658__i45421910461">xxxxxxxx</em></strong>"
<strong id="EN-US_TOPIC_0000001134564658__b254662819280"> }</strong>
<strong id="EN-US_TOPIC_0000001134564658__b6546162815283"> }</strong>
}
}</pre>
<p id="EN-US_TOPIC_0000001134564658__a212a74e9785342f9a44bb4d6d62c25f1">After a token is obtained, the <strong id="EN-US_TOPIC_0000001134564658__b15928143912512">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 <span class="parmvalue" id="EN-US_TOPIC_0000001134564658__parmvalue27267718616"><b>ABCDEFJ....</b></span>, <span class="parmvalue" id="EN-US_TOPIC_0000001134564658__parmvalue4100115163"><b>X-Auth-Token: ABCDEFJ....</b></span> can be added to a request.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_02_0062.html">Calling APIs</a></div>
</div>
</div>