doc-exports/docs/opengauss/api-ref/opengauss_api_0009.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

199 lines
23 KiB
HTML

<a name="EN-US_TOPIC_0000001947569461"></a><a name="EN-US_TOPIC_0000001947569461"></a>
<h1 class="topictitle1">Making an API Request</h1>
<div id="body1592884185064"><p id="EN-US_TOPIC_0000001947569461__p15648656678">This section describes the structure of a REST API and how to call an API. Before calling an API, you need to <a href="https://docs.otc.t-systems.com/en-us/api/iam/en-us_topic_0057845583.html" target="_blank" rel="noopener noreferrer">obtain the user token</a>. The obtained token can then be used to authenticate the calling of other APIs.</p>
<div class="section" id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_section697653216219"><h4 class="sectiontitle">Request URI</h4><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p1327834192114">A request URI consists of the following:</p>
<p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p015994616212"><strong id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_b11186155382110">{URI-scheme}://{Endpoint}/{resource-path}?{query-string}</strong></p>
<p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p16960034182113">Although a request URI is included in a request header, most programming languages or frameworks require the request URI to be separately transmitted, rather than being conveyed in a request message.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_table4443194632512" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters in a URI</caption><thead align="left"><tr id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_row1944414616258"><th align="left" class="cellrowborder" valign="top" width="19.48%" id="mcps1.3.2.5.2.3.1.1"><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p1644484692510"><strong id="EN-US_TOPIC_0000001947569461__b5250153519465">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="80.52%" id="mcps1.3.2.5.2.3.1.2"><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p174441146142511"><strong id="EN-US_TOPIC_0000001947569461__b38899298461">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_row10444144620259"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p154446465251">URI-scheme</p>
</td>
<td class="cellrowborder" valign="top" width="80.52%" headers="mcps1.3.2.5.2.3.1.2 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p8444144692517">Protocol used to transmit requests. All APIs use HTTPS.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_row444414692513"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p7444194610257">Endpoint</p>
</td>
<td class="cellrowborder" valign="top" width="80.52%" headers="mcps1.3.2.5.2.3.1.2 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p244474613259">Domain name or IP address of the server bearing the REST service. The endpoint varies between services in different regions. It can be obtained from <a href="https://docs.otc.t-systems.com/regions-and-endpoints/index.html" target="_blank" rel="noopener noreferrer">Regions and Endpoints</a>.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_row1744454612520"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p14442468257">resource-path</p>
</td>
<td class="cellrowborder" valign="top" width="80.52%" headers="mcps1.3.2.5.2.3.1.2 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p1844412467258">Access path of an API for performing a specified operation. Obtain the path from the URI of an API. For example, the <span class="parmname" id="EN-US_TOPIC_0000001947569461__parmname10118203265616"><b>resource-path</b></span> of the API used to obtain a user token is <span class="parmvalue" id="EN-US_TOPIC_0000001947569461__parmvalue51182032175615"><b>/v3/auth/tokens</b></span>.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_row184441346152515"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p4444154692516">query-string</p>
</td>
<td class="cellrowborder" valign="top" width="80.52%" headers="mcps1.3.2.5.2.3.1.2 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p1444414622514">Query parameter, which is optional. Ensure that a question mark (?) is included before each query parameter that is in the format of "Parameter name=Parameter value". For example, <strong id="EN-US_TOPIC_0000001947569461__b1670793219241">? limit=10</strong> indicates that a maximum of 10 data records will be displayed.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="EN-US_TOPIC_0000001947569461__note16311253154112"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001947569461__p163316534416">To simplify the URI display, each API is provided only with a resource-path and a request method. The <strong id="EN-US_TOPIC_0000001947569461__b9831343135813">URI-scheme</strong> of all APIs is <strong id="EN-US_TOPIC_0000001947569461__b5832643185817">HTTPS</strong>, and the endpoints of all APIs in the same region are identical.</p>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_section5296154118345"><h4 class="sectiontitle">Request Methods</h4><div class="p" id="EN-US_TOPIC_0000001947569461__p46347563325">The HTTP protocol defines the following request methods that can be used to send a request to the server.
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_table1961229113819" frame="border" border="1" rules="all"><caption><b>Table 2 </b>HTTP methods</caption><thead align="left"><tr id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_row86141913816"><th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.3.2.1.2.3.1.1"><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p186147910387"><strong id="EN-US_TOPIC_0000001947569461__b73523284591">Method</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.3.2.1.2.3.1.2"><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p166141293387"><strong id="EN-US_TOPIC_0000001947569461__b95451730105918">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_row146141194381"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p12831539123914">GET</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p2831123916397">Requests the server to return the specified resources.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_row161429103817"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p3831239183912">PUT</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p178311939193911">Requests the server to update specified resources.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_row56141190384"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p68311239113912">POST</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p1583133918391">Requests the server to add resources or perform special operations.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_row861411903812"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p1183153943916">DELETE</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p6831163914392">Requests the server to delete specified resources, for example, an object.</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_row2614199163812"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p1483143915390">PATCH</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p17831173918394">Requests the server to update part of a specified resource.</p>
<p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p9831123911390">If the resource does not exist, the PATCH method creates a resource.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p id="EN-US_TOPIC_0000001947569461__p3759142614815">For example, in the case of 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>, the request method is POST. The request is as follows:</p>
<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001947569461__screen7888377244"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</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/tokens</span>
</pre></div></td></tr></table></div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001947569461__section479119143310"><h4 class="sectiontitle">Request Header</h4><p id="EN-US_TOPIC_0000001947569461__p269363935616">You can also add additional header fields to a request, such as the fields required by a specified URI or HTTP method. For example, add <span class="parmname" id="EN-US_TOPIC_0000001947569461__parmname12001548091"><b>Content-Type</b></span> that defines a request body type to request for the authentication information.</p>
<div class="p" id="EN-US_TOPIC_0000001947569461__p56967114331"><a href="#EN-US_TOPIC_0000001947569461__table1986821153312">Table 3</a> lists common request header fields.
<div class="tablenoborder"><a name="EN-US_TOPIC_0000001947569461__table1986821153312"></a><a name="table1986821153312"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001947569461__table1986821153312" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Common request headers</caption><thead align="left"><tr id="EN-US_TOPIC_0000001947569461__row1286841153311"><th align="left" class="cellrowborder" valign="top" width="19.74%" id="mcps1.3.4.3.2.2.5.1.1"><p id="EN-US_TOPIC_0000001947569461__p178680183310"><strong id="EN-US_TOPIC_0000001947569461__b1611333281012">Name</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="26.5%" id="mcps1.3.4.3.2.2.5.1.2"><p id="EN-US_TOPIC_0000001947569461__p78688118335"><strong id="EN-US_TOPIC_0000001947569461__b761473551016">Description</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20.11%" id="mcps1.3.4.3.2.2.5.1.3"><p id="EN-US_TOPIC_0000001947569461__p58686123316"><strong id="EN-US_TOPIC_0000001947569461__b125258372108">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.650000000000006%" id="mcps1.3.4.3.2.2.5.1.4"><p id="EN-US_TOPIC_0000001947569461__p48681314333"><strong id="EN-US_TOPIC_0000001947569461__b43461139201019">Example Value</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001947569461__row1286861153311"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001947569461__p2086813163316">Host</p>
</td>
<td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001947569461__p58681814333">Requested server information, which can be obtained from the URL of the service API. The value is in the <em id="EN-US_TOPIC_0000001947569461__i19094210714">hostname[:port]</em> format. If the port number is not specified, the default port is used. The default port number for <strong id="EN-US_TOPIC_0000001947569461__b5371537315524">https</strong> is <strong id="EN-US_TOPIC_0000001947569461__b1367631015524">443</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="20.11%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001947569461__p886815123319">No</p>
<p id="EN-US_TOPIC_0000001947569461__p386811116333">This parameter is mandatory for AK/SK authentication.</p>
</td>
<td class="cellrowborder" valign="top" width="33.650000000000006%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001947569461__p486814118330">code.test.com</p>
<p id="EN-US_TOPIC_0000001947569461__p5868161163317">or</p>
<p id="EN-US_TOPIC_0000001947569461__p786841123315">code.test.com:443</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001947569461__row386818143313"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001947569461__p118689123320">Content-Type</p>
</td>
<td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001947569461__p1486815116337">MIME type of the request body. You are advised to use the default value <strong id="EN-US_TOPIC_0000001947569461__b8811101831215">application/json</strong>. For APIs used to upload objects or images, the value can vary depending on the flow type.</p>
</td>
<td class="cellrowborder" valign="top" width="20.11%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001947569461__p1086812114335">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="33.650000000000006%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001947569461__p1186841163310">application/json</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001947569461__row11868419337"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001947569461__p178687119330">Content-Length</p>
</td>
<td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001947569461__p178681813332">Length of the request body. The unit is byte.</p>
</td>
<td class="cellrowborder" valign="top" width="20.11%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001947569461__p18687183316">No</p>
</td>
<td class="cellrowborder" valign="top" width="33.650000000000006%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001947569461__p148689110334">3495</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001947569461__row2868171143313"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001947569461__p586815118338">X-Project-Id</p>
</td>
<td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001947569461__p1586811163312">Project ID. Obtain the project ID by following the instructions in <a href="opengauss_api_0034.html">Obtaining a Project ID</a>.</p>
</td>
<td class="cellrowborder" valign="top" width="20.11%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001947569461__p886812110335">No</p>
</td>
<td class="cellrowborder" valign="top" width="33.650000000000006%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001947569461__p198684143315">e9993fc787d94b6c886cbaa340f9c0f4</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001947569461__row188688113337"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.2.2.5.1.1 "><p id="EN-US_TOPIC_0000001947569461__p198684111335">X-Auth-Token</p>
</td>
<td class="cellrowborder" valign="top" width="26.5%" headers="mcps1.3.4.3.2.2.5.1.2 "><p id="EN-US_TOPIC_0000001947569461__p1086851153317">User token.</p>
<p id="EN-US_TOPIC_0000001947569461__p1057635831">The user token is a response to 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>. This API is the only one that does not require authentication.</p>
<p id="EN-US_TOPIC_0000001947569461__p15868417337">After the request is processed, the value of <strong id="EN-US_TOPIC_0000001947569461__b1240351912157">X-Subject-Token</strong> in the message header is the token value.</p>
</td>
<td class="cellrowborder" valign="top" width="20.11%" headers="mcps1.3.4.3.2.2.5.1.3 "><p id="EN-US_TOPIC_0000001947569461__p4868514338">No</p>
<p id="EN-US_TOPIC_0000001947569461__p986818114339">This parameter is mandatory for token authentication.</p>
</td>
<td class="cellrowborder" valign="top" width="33.650000000000006%" headers="mcps1.3.4.3.2.2.5.1.4 "><p id="EN-US_TOPIC_0000001947569461__p27152505302">The following is part of an example token:</p>
<p id="EN-US_TOPIC_0000001947569461__p168689113318">MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="p" id="EN-US_TOPIC_0000001947569461__p42118461957">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> does not require authentication. Therefore, only the <span class="parmname" id="EN-US_TOPIC_0000001947569461__parmname748316232173"><b>Content-Type</b></span> field needs to be added to requests for calling the API. An example of such requests is as follows.<div class="codecoloring" codetype="Java" id="EN-US_TOPIC_0000001947569461__screen73731462616"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</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/tokens</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>
</pre></div></td></tr></table></div>
</div>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_section1437471411"><h4 class="sectiontitle">(Optional) Request Body</h4><p id="EN-US_TOPIC_0000001947569461__en-us_topic_0113746487_p76011911717">This part is optional. A request body is generally sent in a structured format (for example, JSON or XML), corresponding to <strong id="EN-US_TOPIC_0000001947569461__b3917205491819">Content-Type</strong> in the request header, and is used to transfer content other than the request header. If the request body contains full-width characters, these characters must be coded in UTF-8.</p>
<p id="EN-US_TOPIC_0000001947569461__p1847214711331">The request body varies according to the APIs. Certain APIs do not require the request body, such as the GET and DELETE APIs.</p>
<div class="p" id="EN-US_TOPIC_0000001947569461__p105261225101112">In the case of 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>, the request parameters and parameter description can be obtained from the API request. The following provides an example request with a body included. Replace <em id="EN-US_TOPIC_0000001947569461__i127561847280"><strong id="EN-US_TOPIC_0000001947569461__b18756547283">username</strong></em>, <em id="EN-US_TOPIC_0000001947569461__i1375714112814"><strong id="EN-US_TOPIC_0000001947569461__b19756444284">domainname</strong></em>, <strong id="EN-US_TOPIC_0000001947569461__b87576492818"><em id="EN-US_TOPIC_0000001947569461__i875794142816">********</em></strong> (login password), and <strong id="EN-US_TOPIC_0000001947569461__b875711416289"><em id="EN-US_TOPIC_0000001947569461__i1375719416289">xxxxxxxxxxxxxxxxxx</em></strong> (project name) with actual values. You can obtain the values from <a href="https://docs.otc.t-systems.com/regions-and-endpoints/index.html" target="_blank" rel="noopener noreferrer">Regions and Endpoints</a>.<div class="note" id="EN-US_TOPIC_0000001947569461__note15403511418"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001947569461__p199011223194814"><strong id="EN-US_TOPIC_0000001947569461__b1737213132194">scope</strong> specifies where a token takes effect. In the example, the token takes effect only on the resources specified by the project ID. You can set <strong id="EN-US_TOPIC_0000001947569461__b1153215289455">scope</strong> to an account or a project under an account. In the following example, the token takes effect only for the resources in a specified project. For more information about this API, see <a href="https://docs.otc.t-systems.com/en-us/api/iam/en-us_topic_0057845583.html" target="_blank" rel="noopener noreferrer">Obtaining a User Token</a>.</p>
</div></div>
</div>
<pre class="screen" id="EN-US_TOPIC_0000001947569461__screen18404136819">
POST https://{{Endpoint}}/v3/auth/tokens
Content-Type: application/json
{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": "<em id="EN-US_TOPIC_0000001947569461__i13737202316812"><strong id="EN-US_TOPIC_0000001947569461__b177382231389">username</strong></em>",
"password": "<strong id="EN-US_TOPIC_0000001947569461__b1673802312811"><em id="EN-US_TOPIC_0000001947569461__i47381423788">********</em></strong>",
"domain": {
"name": "<em id="EN-US_TOPIC_0000001947569461__i17738923487"><strong id="EN-US_TOPIC_0000001947569461__b107385233815">domainname</strong></em>"
}
}
}
},
"scope": {
"project": {
"name": "<strong id="EN-US_TOPIC_0000001947569461__b373842313817"><em id="EN-US_TOPIC_0000001947569461__i973819231089">xxxxxxxxxxxxxxxxxx</em></strong>"
}
}
}
}</pre>
<p id="EN-US_TOPIC_0000001947569461__p1859663401915">If all data required for the API request is available, you can send the request to call the API through <a href="https://curl.haxx.se/" target="_blank" rel="noopener noreferrer">curl</a>, <a href="https://www.getpostman.com/" target="_blank" rel="noopener noreferrer">Postman</a>, or coding. For the API used to obtain a user token, <strong id="EN-US_TOPIC_0000001947569461__b18179743192014">x-subject-token</strong> in the response header is the desired user token. This token can then be used to authenticate the calling of other APIs.</p>
</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>