forked from docs/doc-exports
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>
45 lines
2.8 KiB
HTML
45 lines
2.8 KiB
HTML
<a name="nosql_05_0009"></a><a name="nosql_05_0009"></a>
|
|
|
|
<h1 class="topictitle1">Authentication</h1>
|
|
<div id="body0000001354538568"><p class="MsoNormal" id="nosql_05_0009__p127281235414"><span id="nosql_05_0009__text134372513459">GeminiDB</span><span id="nosql_05_0009__text84381051174512"></span> supports token-based authentication.</p>
|
|
<div class="note" id="nosql_05_0009__note16278457204513"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="nosql_05_0009__p1627913575453">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="nosql_05_0009__p135791862430">A token specifies temporary permissions in a computer system. During API authentication using a token, the token is added to a request to get permissions for calling the API.</p>
|
|
<p id="nosql_05_0009__p194994815456">If you want to use a token for authentication, you need to obtain the user's token and add <strong id="nosql_05_0009__b6492155018386">X-Auth-Token</strong> to the request header of the service API to make an API call.</p>
|
|
<p id="nosql_05_0009__p8530989556">When you call an API to obtain a user token, set <strong id="nosql_05_0009__b1369464943913">auth.scope</strong> in the request body to <strong id="nosql_05_0009__b1869413496395">project</strong>.</p>
|
|
<pre class="codeblock" id="nosql_05_0009__codeblock18568163013547">{
|
|
"auth": {
|
|
"identity": {
|
|
"methods": [
|
|
"password"
|
|
],
|
|
"password": {
|
|
"user": {
|
|
"name": "<em id="nosql_05_0009__i1570430165414">username</em>",
|
|
"password": "<em id="nosql_05_0009__i14570330165415">password</em>",
|
|
"domain": {
|
|
"name": "<em id="nosql_05_0009__i185706308546">domainname</em>"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"scope": {
|
|
"project": {
|
|
"name": "xxxxxxxx"
|
|
}
|
|
}
|
|
}
|
|
}</pre>
|
|
<p id="nosql_05_0009__p14474111714512">After a token is obtained, add field <strong id="nosql_05_0009__b086233514314">X-Auth-Token</strong> to the request header to specify the token when other APIs are called. For example, if the token is <strong id="nosql_05_0009__b13692125216435">ABCDEFJ....</strong>, add <strong id="nosql_05_0009__b669335284315">X-Auth-Token: ABCDEFJ....</strong> to a request header as follows:</p>
|
|
<pre class="screen" id="nosql_05_0009__screen1047431725116">
|
|
POST https://{{Endpoint}}/v3/auth/projects
|
|
Content-Type: application/json
|
|
<strong id="nosql_05_0009__b847411765114">X-Auth-Token: ABCDEFJ....</strong></pre>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="nosql_05_0007.html">Calling APIs</a></div>
|
|
</div>
|
|
</div>
|
|
|