doc-exports/docs/opengauss/api-ref/opengauss_api_0010.html
Ru, Li Yi d97aea4dd2 opengauss_api
Reviewed-by: Boka, Ladislav <ladislav.boka@t-systems.com>
Co-authored-by: Ru, Li Yi <liyiru7@huawei.com>
Co-committed-by: Ru, Li Yi <liyiru7@huawei.com>
2024-09-06 09:04:21 +00:00

50 lines
5.0 KiB
HTML

<a name="EN-US_TOPIC_0000001917130680"></a><a name="EN-US_TOPIC_0000001917130680"></a>
<h1 class="topictitle1">Authentication</h1>
<div id="body1592884185078"><p id="EN-US_TOPIC_0000001917130680__p27556670">Token authentication must be performed to call APIs.</p>
<p id="EN-US_TOPIC_0000001917130680__p4531593915538">Token-based authentication: Requests are authenticated using a token.</p>
<div class="section" id="EN-US_TOPIC_0000001917130680__section12338193016620"><h4 class="sectiontitle">Token Authentication</h4><div class="note" id="EN-US_TOPIC_0000001917130680__note1664421016716"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001917130680__p464431018713">The validity period of a token is 24 hours. If a token is required, the system caches the token to avoid frequent calling.</p>
</div></div>
<p id="EN-US_TOPIC_0000001917130680__p364417101710">A token specifies temporary permissions in a computer system. During API authentication using a token, the token is added to requests to get permissions for calling the API.</p>
<pre class="screen" id="EN-US_TOPIC_0000001917130680__screen1523316215617">{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": "<strong id="EN-US_TOPIC_0000001917130680__b523211213611"><em id="EN-US_TOPIC_0000001917130680__i152321121768">username</em></strong>",
"password": "<strong id="EN-US_TOPIC_0000001917130680__b1423242864"><em id="EN-US_TOPIC_0000001917130680__i102321723618">********</em></strong>",
"domain": {
"name": "<strong id="EN-US_TOPIC_0000001917130680__b1232182160"><em id="EN-US_TOPIC_0000001917130680__i142321521463">domainname</em></strong>"
}
}
}
},
<strong id="EN-US_TOPIC_0000001917130680__b172326214617"> "scope": {</strong><strong id="EN-US_TOPIC_0000001917130680__b122324215616"> </strong>
<strong id="EN-US_TOPIC_0000001917130680__b32321024619"> </strong><strong id="EN-US_TOPIC_0000001917130680__b62336216618"> "project": {</strong><strong id="EN-US_TOPIC_0000001917130680__b1623362867"> </strong>
<strong id="EN-US_TOPIC_0000001917130680__b1423332562"> </strong><strong id="EN-US_TOPIC_0000001917130680__b8233162061"> "name": "<em id="EN-US_TOPIC_0000001917130680__i6233321063">xxxxxxxx</em>"</strong><strong id="EN-US_TOPIC_0000001917130680__b123313217620"> </strong>
<strong id="EN-US_TOPIC_0000001917130680__b1423332869"> </strong><strong id="EN-US_TOPIC_0000001917130680__b52331822611"> }</strong><strong id="EN-US_TOPIC_0000001917130680__b1223313212617"> </strong>
<strong id="EN-US_TOPIC_0000001917130680__b182333215616"> </strong><strong id="EN-US_TOPIC_0000001917130680__b17233172167"> }</strong><strong id="EN-US_TOPIC_0000001917130680__b122332212612"> </strong>
}
}
</pre>
</div>
<p id="EN-US_TOPIC_0000001917130680__p116169153412">In <a href="opengauss_api_0009.html">Making an API Request</a>, the process of calling the API used to <a href="https://docs.otc.t-systems.com/en-us/api/iam/en-us_topic_0057845583.html" target="_blank" rel="noopener noreferrer">obtain a user token</a> is described.</p>
<p id="EN-US_TOPIC_0000001917130680__p9691122114266">After a token is obtained, add the <strong id="EN-US_TOPIC_0000001917130680__b1144244172713">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_0000001917130680__parmvalue1038232518315"><b>ABCDEFJ....</b></span>, <span class="parmvalue" id="EN-US_TOPIC_0000001917130680__parmvalue10383725113110"><b>X-Auth-Token: ABCDEFJ....</b></span> can be added to a request as follows:</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001917130680__screen11189101154015"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">POST</span><span class="w"> </span><span class="n">https</span><span class="p">:</span><span class="c1">//{{Endpoint}}/v3/auth/projects</span>
<span class="n">Content</span><span class="o">-</span><span class="n">Type</span><span class="p">:</span><span class="w"> </span><span class="n">application</span><span class="o">/</span><span class="n">json</span>
<span class="n">X</span><span class="o">-</span><span class="n">Auth</span><span class="o">-</span><span class="n">Token</span><span class="p">:</span><span class="w"> </span><span class="n">ABCDEFJ</span><span class="p">....</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="opengauss_api_0008.html">Calling APIs</a></div>
</div>
</div>