doc-exports/docs/sfs/api-ref/sfs_02_0009.html
zhangyue 49ac6fa9ce SFS HPC API DOC
Reviewed-by: Miskanin, Jan <jan.miskanin@t-systems.com>
Co-authored-by: zhangyue <zhangyue164@huawei.com>
Co-committed-by: zhangyue <zhangyue164@huawei.com>
2024-08-16 12:25:57 +00:00

233 lines
27 KiB
HTML

<a name="sfs_02_0009"></a><a name="sfs_02_0009"></a>
<h1 class="topictitle1">Making an API Request</h1>
<div id="body1559725760180"><p id="sfs_02_0009__en-us_topic_0121682347_p15648656678">This section describes the structure of a REST API request, and uses the IAM API for <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> as an example to demonstrate how to call an API. The obtained token can then be used to authenticate the calling of other APIs.</p>
<div class="section" id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_section697653216219"><h4 class="sectiontitle">Request URI</h4><p id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p1327834192114">A request URI is in the following format:</p>
<p id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p015994616212"><strong id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_b11186155382110">{URI-scheme}://{Endpoint}/{resource-path}?{query-string}</strong></p>
<p id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p16960034182113">Although a request URI is included in the request header, most programming languages or frameworks require the request URI to be transmitted separately.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_table4443194632512" frame="border" border="1" rules="all"><caption><b>Table 1 </b>URI parameter description</caption><thead align="left"><tr id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p1644484692510">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="80.52%" id="mcps1.3.2.5.2.3.1.2"><p id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p174441146142511">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_row10444144620259"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p8444144692517">Protocol used to transmit requests. All APIs use HTTPS.</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_row954145705120"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_p16542579519">Endpoint</p>
</td>
<td class="cellrowborder" valign="top" width="80.52%" headers="mcps1.3.2.5.2.3.1.2 "><p id="sfs_02_0009__en-us_topic_0121682347_p17449913195210">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="sfs_02_0001.html#sfs_02_0001__table10404183115620">Regions and Endpoints</a>.</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_row1744454612520"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_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 <strong id="sfs_02_0009__en-us_topic_0121682347_b039165544610">resource-path</strong> of the API used to obtain a user token is <span class="parmvalue" id="sfs_02_0009__en-us_topic_0121682347_parmvalue94075510467"><b>/v3/auth/tokens</b></span>.</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_row184441346152515"><td class="cellrowborder" valign="top" width="19.48%" headers="mcps1.3.2.5.2.3.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_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 <em id="sfs_02_0009__en-us_topic_0121682347_i971081618526">Parameter name</em>=<em id="sfs_02_0009__en-us_topic_0121682347_i19711131618528">Parameter value</em>. For example, <strong id="sfs_02_0009__en-us_topic_0121682347_b6711131610525">? limit=10</strong> indicates that a maximum of 10 data records will be displayed.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="sfs_02_0009__en-us_topic_0121682347_note16311253154112"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="sfs_02_0009__en-us_topic_0121682347_p163316534416">To simplify the URI display in this document, each API is provided only with a <strong id="sfs_02_0009__en-us_topic_0121682347_b285342715125">resource-path</strong> and a request method. The <strong id="sfs_02_0009__en-us_topic_0121682347_b6442828111317">URI-scheme</strong> of all APIs is <strong id="sfs_02_0009__en-us_topic_0121682347_b1158113451310">HTTPS</strong>, and the endpoints of all APIs in the same region are identical.</p>
</div></div>
</div>
<div class="section" id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_section5296154118345"><h4 class="sectiontitle">Request Methods</h4><div class="p" id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_table1961229113819" frame="border" border="1" rules="all"><caption><b>Table 2 </b>HTTP methods</caption><thead align="left"><tr id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p186147910387">Method</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="70%" id="mcps1.3.3.2.1.2.3.1.2"><p id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p166141293387">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_row146141194381"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p2831123916397">Requests the server to return specified resources.</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_row161429103817"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p178311939193911">Requests the server to update specified resources.</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_row56141190384"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p1583133918391">Requests the server to add resources or perform special operations.</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_row861411903812"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p6831163914392">Requests the server to delete specified resources, for example, an object.</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_row5614119183810"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p78314395393">HEAD</p>
</td>
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.3.3.2.1.2.3.1.2 "><p id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p38311239153920">Same as GET except that the server must return only the response header.</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_row2614199163812"><td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.3.2.1.2.3.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p17831173918394">Requests the server to update partial content of a specified resource.</p>
<p id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p9831123911390">If the resource does not exist, a new resource will be created.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p id="sfs_02_0009__en-us_topic_0121682347_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 <span class="parmname" id="sfs_02_0009__en-us_topic_0121682347_parmname369469101"><b>POST</b></span>. The request is as follows:</p>
<div class="codecoloring" codetype="Java" id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_section479119143310"><h4 class="sectiontitle">Request Header</h4><p id="sfs_02_0009__en-us_topic_0121682347_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, to request for the authentication information, add <strong id="sfs_02_0009__en-us_topic_0121682347_b1432464618179">Content-Type</strong>, which specifies the request body type.</p>
<div class="p" id="sfs_02_0009__en-us_topic_0121682347_p56967114331">Common request header fields are as follows.
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="sfs_02_0009__en-us_topic_0121682347_table1986821153312" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Common request header fields</caption><thead align="left"><tr id="sfs_02_0009__en-us_topic_0121682347_row1286841153311"><th align="left" class="cellrowborder" valign="top" width="19.74%" id="mcps1.3.4.3.1.2.5.1.1"><p id="sfs_02_0009__en-us_topic_0121682347_p178680183310">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="33.629999999999995%" id="mcps1.3.4.3.1.2.5.1.2"><p id="sfs_02_0009__en-us_topic_0121682347_p78688118335">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="22.75%" id="mcps1.3.4.3.1.2.5.1.3"><p id="sfs_02_0009__en-us_topic_0121682347_p58686123316">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="23.880000000000003%" id="mcps1.3.4.3.1.2.5.1.4"><p id="sfs_02_0009__en-us_topic_0121682347_p48681314333">Example Value</p>
</th>
</tr>
</thead>
<tbody><tr id="sfs_02_0009__en-us_topic_0121682347_row1286861153311"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.1.2.5.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_p2086813163316">Host</p>
</td>
<td class="cellrowborder" valign="top" width="33.629999999999995%" headers="mcps1.3.4.3.1.2.5.1.2 "><p id="sfs_02_0009__en-us_topic_0121682347_p58681814333">Specifies the server domain name and port number of the resources being requested. The value can be obtained from the URL of the service API. The value is in the format of <em id="sfs_02_0009__en-us_topic_0121682347_i1012185414574">Hostname:Port number</em>. If the port number is not specified, the default port is used. The default port number for <strong id="sfs_02_0009__en-us_topic_0121682347_b5371537315524">https</strong> is <strong id="sfs_02_0009__en-us_topic_0121682347_b1367631015524">443</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="22.75%" headers="mcps1.3.4.3.1.2.5.1.3 "><p id="sfs_02_0009__en-us_topic_0121682347_p886815123319">No</p>
<p id="sfs_02_0009__en-us_topic_0121682347_p386811116333">This field is mandatory for AK/SK authentication.</p>
</td>
<td class="cellrowborder" valign="top" width="23.880000000000003%" headers="mcps1.3.4.3.1.2.5.1.4 "><p id="sfs_02_0009__en-us_topic_0121682347_p486814118330">code.test.com</p>
<p id="sfs_02_0009__en-us_topic_0121682347_p5868161163317">or</p>
<p id="sfs_02_0009__en-us_topic_0121682347_p786841123315">code.test.com:443</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_row386818143313"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.1.2.5.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_p118689123320">Content-Type</p>
</td>
<td class="cellrowborder" valign="top" width="33.629999999999995%" headers="mcps1.3.4.3.1.2.5.1.2 "><p id="sfs_02_0009__en-us_topic_0121682347_p1486815116337">Specifies the type (or format) of the message body. The default value <strong id="sfs_02_0009__en-us_topic_0121682347_b16961103217166">application/json</strong> is recommended. Other values of this field will be provided for specific APIs if any.</p>
</td>
<td class="cellrowborder" valign="top" width="22.75%" headers="mcps1.3.4.3.1.2.5.1.3 "><p id="sfs_02_0009__en-us_topic_0121682347_p1086812114335">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="23.880000000000003%" headers="mcps1.3.4.3.1.2.5.1.4 "><p id="sfs_02_0009__en-us_topic_0121682347_p1186841163310">application/json</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_row11868419337"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.1.2.5.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_p178687119330">Content-Length</p>
</td>
<td class="cellrowborder" valign="top" width="33.629999999999995%" headers="mcps1.3.4.3.1.2.5.1.2 "><p id="sfs_02_0009__en-us_topic_0121682347_p178681813332">Specifies the length of the request body. The unit is byte.</p>
</td>
<td class="cellrowborder" valign="top" width="22.75%" headers="mcps1.3.4.3.1.2.5.1.3 "><p id="sfs_02_0009__en-us_topic_0121682347_p18687183316">No</p>
</td>
<td class="cellrowborder" valign="top" width="23.880000000000003%" headers="mcps1.3.4.3.1.2.5.1.4 "><p id="sfs_02_0009__en-us_topic_0121682347_p148689110334">3495</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_row2868171143313"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.1.2.5.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_p586815118338">X-Project-Id</p>
</td>
<td class="cellrowborder" valign="top" width="33.629999999999995%" headers="mcps1.3.4.3.1.2.5.1.2 "><p id="sfs_02_0009__en-us_topic_0121682347_p1586811163312">Specifies the project ID. Obtain the project ID by following the instructions in <a href="sfs_02_0090.html#sfs_02_0090">Obtaining a Project ID</a>.</p>
</td>
<td class="cellrowborder" valign="top" width="22.75%" headers="mcps1.3.4.3.1.2.5.1.3 "><p id="sfs_02_0009__en-us_topic_0121682347_p886812110335">No</p>
</td>
<td class="cellrowborder" valign="top" width="23.880000000000003%" headers="mcps1.3.4.3.1.2.5.1.4 "><p id="sfs_02_0009__en-us_topic_0121682347_p198684143315">e9993fc787d94b6c886cbaa340f9c0f4</p>
</td>
</tr>
<tr id="sfs_02_0009__en-us_topic_0121682347_row188688113337"><td class="cellrowborder" valign="top" width="19.74%" headers="mcps1.3.4.3.1.2.5.1.1 "><p id="sfs_02_0009__en-us_topic_0121682347_p198684111335">X-Auth-Token</p>
</td>
<td class="cellrowborder" valign="top" width="33.629999999999995%" headers="mcps1.3.4.3.1.2.5.1.2 "><p id="sfs_02_0009__en-us_topic_0121682347_p1086851153317">Specifies the user token.</p>
<p id="sfs_02_0009__en-us_topic_0121682347_p1057635831">It is a response to the API for <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> (This is the only API that does not require authentication).</p>
<p id="sfs_02_0009__en-us_topic_0121682347_p15868417337">After the request is processed, the value of <strong id="sfs_02_0009__en-us_topic_0121682347_b842352706205322">X-Subject-Token</strong> in the response header is the token value.</p>
</td>
<td class="cellrowborder" valign="top" width="22.75%" headers="mcps1.3.4.3.1.2.5.1.3 "><p id="sfs_02_0009__en-us_topic_0121682347_p4868514338">No</p>
<p id="sfs_02_0009__en-us_topic_0121682347_p986818114339">This field is mandatory for token authentication.</p>
</td>
<td class="cellrowborder" valign="top" width="23.880000000000003%" headers="mcps1.3.4.3.1.2.5.1.4 "><p id="sfs_02_0009__en-us_topic_0121682347_p27152505302">The following is part of an example token:</p>
<p id="sfs_02_0009__en-us_topic_0121682347_p168689113318">MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="note" id="sfs_02_0009__en-us_topic_0121682347_note13771123325011"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="sfs_02_0009__en-us_topic_0121682347_p1513412221808">In addition to supporting authentication using tokens, APIs support authentication using AK/SK, which uses SDKs to sign a request. During the signature, the <strong id="sfs_02_0009__en-us_topic_0121682347_b1411717123020">Authorization</strong> (signature authentication) and <strong id="sfs_02_0009__en-us_topic_0121682347_b91187122001">X-Sdk-Date</strong> (time when a request is sent) headers are automatically added in the request.</p>
<p id="sfs_02_0009__en-us_topic_0121682347_p1577123365010">For more details, see "Authentication Using AK/SK" in <a href="sfs_02_0011.html">Authentication</a>.</p>
</div></div>
<p id="sfs_02_0009__en-us_topic_0121682347_p9786614164616">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 <strong id="sfs_02_0009__en-us_topic_0121682347_b36811913115214">Content-Type</strong> field needs to be added to requests for calling the API. An example of such requests is as follows:</p>
<div class="codecoloring" codetype="Java" id="sfs_02_0009__en-us_topic_0121682347_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 class="section" id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_section1437471411"><h4 class="sectiontitle">(Optional) Request Body</h4><p id="sfs_02_0009__en-us_topic_0121682347_en-us_topic_0113746487_p76011911717">This part is optional. The body of a request is often sent in a structured format (for example, JSON or XML) as specified in the <strong id="sfs_02_0009__en-us_topic_0121682347_b190810592581">Content-Type</strong> header field. The request body transfers content except the request header.</p>
<p id="sfs_02_0009__en-us_topic_0121682347_p1847214711331">The request body varies between APIs. Some APIs do not require the request body, such as the APIs requested using the GET and DELETE methods.</p>
<p id="sfs_02_0009__en-us_topic_0121682347_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="sfs_02_0009__en-us_topic_0121682347_i23381811961">username</em>, <em id="sfs_02_0009__en-us_topic_0121682347_i11339511960">domainname</em>, <em id="sfs_02_0009__en-us_topic_0121682347_i1233991465">$ADMIN_PASS</em> (login password), and <em id="sfs_02_0009__en-us_topic_0121682347_i163394112619">xxxxxxxxxxxxxxxxxx</em> (project name) with the actual values. Obtain a project name from <a href="sfs_02_0001.html#sfs_02_0001__table10404183115620">Regions and Endpoints</a>.</p>
<div class="note" id="sfs_02_0009__en-us_topic_0121682347_note15403511418"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="sfs_02_0009__en-us_topic_0121682347_p199011223194814">The <strong id="sfs_02_0009__en-us_topic_0121682347_b1186815753415">scope</strong> parameter specifies where a token takes effect. You can set <strong id="sfs_02_0009__en-us_topic_0121682347_b1246371618347">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 class="codecoloring" codetype="Java" id="sfs_02_0009__en-us_topic_0121682347_screen6140617194816"><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>
<span class="normal"> 4</span>
<span class="normal"> 5</span>
<span class="normal"> 6</span>
<span class="normal"> 7</span>
<span class="normal"> 8</span>
<span class="normal"> 9</span>
<span class="normal">10</span>
<span class="normal">11</span>
<span class="normal">12</span>
<span class="normal">13</span>
<span class="normal">14</span>
<span class="normal">15</span>
<span class="normal">16</span>
<span class="normal">17</span>
<span class="normal">18</span>
<span class="normal">19</span>
<span class="normal">20</span>
<span class="normal">21</span>
<span class="normal">22</span>
<span class="normal">23</span>
<span class="normal">24</span>
<span class="normal">25</span>
<span class="normal">26</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>
<span class="p">{</span>
<span class="w"> </span><span class="s">&quot;auth&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="s">&quot;identity&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="s">&quot;methods&quot;</span><span class="p">:</span><span class="w"> </span><span class="o">[</span>
<span class="w"> </span><span class="s">&quot;password&quot;</span>
<span class="w"> </span><span class="o">]</span><span class="p">,</span>
<span class="w"> </span><span class="s">&quot;password&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="s">&quot;user&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="s">&quot;name&quot;</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;username&quot;</span><span class="p">,</span>
<span class="w"> </span><span class="s">&quot;password&quot;</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;$ADMIN_PASS&quot;</span><span class="p">,</span><span class="w"> </span><span class="c1">//You are advised to store it in ciphertext in the configuration file or an environment variable and decrypt it when needed to ensure security.</span>
<span class="w"> </span><span class="s">&quot;domain&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="s">&quot;name&quot;</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;domainname&quot;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">},</span>
<span class="w"> </span><span class="s">&quot;scope&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="s">&quot;project&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="s">&quot;name&quot;</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;xxxxxxxxxxxxxxxxxx&quot;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>
</pre></div></td></tr></table></div>
</div>
<p id="sfs_02_0009__en-us_topic_0121682347_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. In the response to the API used to obtain a user token, <strong id="sfs_02_0009__en-us_topic_0121682347_b1176039479">X-Subject-Token</strong> 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="sfs_02_0008.html">Calling APIs</a></div>
</div>
</div>