forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Yang, Tong <yangtong2@huawei.com> Co-committed-by: Yang, Tong <yangtong2@huawei.com>
228 lines
24 KiB
HTML
228 lines
24 KiB
HTML
<a name="mrs_02_0008"></a><a name="mrs_02_0008"></a>
|
|
|
|
<h1 class="topictitle1">Making an API Request</h1>
|
|
<div id="body1559185429880"><p id="mrs_02_0008__en-us_topic_0121682347_p15648656678">This section describes the structure of a REST API, 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 request authentication</a> as an example to demonstrate how to call an API. The obtained token is used to authenticate the calling of other APIs.</p>
|
|
<div class="section" id="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_section697653216219"><h4 class="sectiontitle">Request URI</h4><p id="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_p1327834192114">A request URI is in the following format:</p>
|
|
<p id="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_p015994616212"><strong id="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_b11186155382110">{URI-scheme}://{Endpoint}/{resource-path}?{query-string}</strong></p>
|
|
<p id="mrs_02_0008__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="mrs_02_0008__table1637277135646" frame="border" border="1" rules="all"><caption><b>Table 1 </b>URI parameter description</caption><thead align="left"><tr id="mrs_02_0008__row42856273135646"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.2.5.2.3.1.1"><p id="mrs_02_0008__p48806094135646">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="80%" id="mcps1.3.2.5.2.3.1.2"><p id="mrs_02_0008__p60979560135646">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="mrs_02_0008__row50093829135713"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.5.2.3.1.1 "><p id="mrs_02_0008__p13294067135723">URI-scheme</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80%" headers="mcps1.3.2.5.2.3.1.2 "><p id="mrs_02_0008__p188391318133718">Protocol used to transmit requests. All APIs use HTTPS.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__row40397318135646"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.5.2.3.1.1 "><p id="mrs_02_0008__p50957329135646">Endpoint</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80%" headers="mcps1.3.2.5.2.3.1.2 "><p id="mrs_02_0008__p33902960135646">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="mrs_02_0008__row1377075135915"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.5.2.3.1.1 "><p id="mrs_02_0008__p44434271135915">resource-path</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80%" headers="mcps1.3.2.5.2.3.1.2 "><p id="mrs_02_0008__p42406232135915">Access path of an API for performing a specified operation. Obtain the path from the URI of an API. For example, the <strong id="mrs_02_0008__b3223259171119">resource-path</strong> 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 request authentication</a> is <span class="parmvalue" id="mrs_02_0008__parmvalue12260595111"><b>/v3/auth/tokens</b></span>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__row11383469135646"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.2.5.2.3.1.1 "><p id="mrs_02_0008__p62949675135953">query-string</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="80%" headers="mcps1.3.2.5.2.3.1.2 "><p id="mrs_02_0008__p29437205428">Query parameter, which is optional. Ensure that a question mark (?) is included before each query parameter that is in the format of "<em id="mrs_02_0008__i565516141204">Parameter name=Parameter value</em>". For example, <strong id="mrs_02_0008__b865615141309">? limit=10</strong> indicates that a maximum of 10 data records will be displayed.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="note" id="mrs_02_0008__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="mrs_02_0008__en-us_topic_0121682347_p163316534416">To simplify the URI display in this document, each API is provided only with a <strong id="mrs_02_0008__b851317397118">resource-path</strong> and a request method. The <strong id="mrs_02_0008__b1847214431611">URI-scheme</strong> of all APIs is <strong id="mrs_02_0008__b12473184311113">HTTPS</strong>, and the endpoints of all APIs in the same region are identical.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_section5296154118345"><h4 class="sectiontitle">Request Methods</h4><div class="p" id="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_p186147910387"><strong id="mrs_02_0008__b472420154315">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="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_p166141293387"><strong id="mrs_02_0008__b1891617238">Description</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_p2831123916397">Requests the server to return specified resources.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_p178311939193911">Requests the server to update specified resources.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_p1583133918391">Requests the server to add resources or perform special operations.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_p17831173918394">Requests the server to update partial content of a specified resource.</p>
|
|
<p id="mrs_02_0008__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="mrs_02_0008__en-us_topic_0121682347_p3759142614815">In the URI of the API to <a href="https://docs.otc.t-systems.com/en-us/api/iam/en-us_topic_0057845583.html" target="_blank" rel="noopener noreferrer">obtain request authentication</a>, you can see that the request method is <span class="parmname" id="mrs_02_0008__parmname12281203551315"><b>POST</b></span>. The request is as follows:</p>
|
|
<pre class="screen" id="mrs_02_0008__en-us_topic_0121682347_screen7888377244">POST https://{{endpoint}}/v3/auth/tokens</pre>
|
|
</div>
|
|
<div class="section" id="mrs_02_0008__en-us_topic_0121682347_section479119143310"><h4 class="sectiontitle">Request Header</h4><p id="mrs_02_0008__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 <span class="parmname" id="mrs_02_0008__parmname86187245614"><b>Content-Type</b></span>, which specifies the request body type.</p>
|
|
<p id="mrs_02_0008__en-us_topic_0121682347_p56967114331"><a href="#mrs_02_0008__td181b06f1c0949cb913acd8d77f21ec3">Table 3</a> lists common request header fields.</p>
|
|
|
|
<div class="tablenoborder"><a name="mrs_02_0008__td181b06f1c0949cb913acd8d77f21ec3"></a><a name="td181b06f1c0949cb913acd8d77f21ec3"></a><table cellpadding="4" cellspacing="0" summary="" id="mrs_02_0008__td181b06f1c0949cb913acd8d77f21ec3" frame="border" border="1" rules="all"><caption><b>Table 3 </b>Common request header fields</caption><thead align="left"><tr id="mrs_02_0008__r97d2c57e12614bd3afdc94a4204ed595"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.4.2.5.1.1"><p id="mrs_02_0008__aa019e06442ea43f7a2dd236b9eeb153c">Field</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.4.4.2.5.1.2"><p id="mrs_02_0008__a0b5237510efb47c185142788a435c90a">Description</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.4.2.5.1.3"><p id="mrs_02_0008__a8df98fec2ab9432c90753890865721a1">Mandatory</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="30%" id="mcps1.3.4.4.2.5.1.4"><p id="mrs_02_0008__en-us_topic_0037324703_p865237161145">Example</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="mrs_02_0008__r775e22ddde31427cb0c75310d3b275f5"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.1 "><p id="mrs_02_0008__ad5553c8196a14fbcb91cb55152fee53d">X-Sdk-Date</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.2 "><p id="mrs_02_0008__a7cd5e01a2bc34080b44f606c2c248dc7">Time when the request is sent. The time is in <strong id="mrs_02_0008__b3354142286">YYYYMMDD'T'HHMMSS'Z'</strong> format.</p>
|
|
<p id="mrs_02_0008__a5ea5e42d645143bbbae5f9c4ab452d7d">The value is the current Greenwich Mean Time (GMT) of the system.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.3 "><p id="mrs_02_0008__ab64471a82ff44053a057c927cbf9ddc9">This field is mandatory for AK/SK-based authentication.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.4 "><p id="mrs_02_0008__a3e18fe766b9a4185830a0fe282eb2680">20150907T101459Z</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__r982b99c7ac074e80b63e96059bc375ff"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.1 "><p id="mrs_02_0008__a6a9ab4af31ef41978c7cd032050ae14a">Host</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.2 "><p id="mrs_02_0008__aaa38a9c8e2dc4fb78234cbb5c1cd580d">Server information of the resource being requested. The value can be obtained from the URL of a service API. The value is <strong id="mrs_02_0008__b0331141320181">hostname[:port]</strong>. If the port number is not specified, the default port is used. The default port number for HTTPS is <strong id="mrs_02_0008__b817353814182">443</strong>.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.3 "><p id="mrs_02_0008__a084e3b07cf104f05944d08ef2a96b1c4">This field is mandatory for AK/SK-based authentication.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.4 "><p id="mrs_02_0008__a8de4dbac3b7a483b9d39efbdf632998a">code.test.com</p>
|
|
<p id="mrs_02_0008__ac8a2d0ee992c40cfa38782c0b85210a9">or</p>
|
|
<p id="mrs_02_0008__ab29d121a7fb94fe3822dca91b79fe760">code.test.com:443</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__rc7911eda8b784dceb1da661d56877f0c"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.1 "><p id="mrs_02_0008__a5f1759adb3ce437a842cc9af6a3fb071">Content-Type</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.2 "><p id="mrs_02_0008__p632810083617">MIME type of the request body This field is mandatory and its default value is <strong id="mrs_02_0008__b8846115917192">application/json</strong>. Other values of this field will be provided for specific APIs if any.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.3 "><p id="mrs_02_0008__a2ca751e0d5904460aae7f6d5f5dc3334">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.4 "><p id="mrs_02_0008__a17e3634848fc49ae9ea11717665e49ea">application/json</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__r38eb00e3fde947918d9a8cf46c11b74f"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.1 "><p id="mrs_02_0008__aa2ffb672489a4ff4b2b47b0ee711625e">Content-Length</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.2 "><p id="mrs_02_0008__a67d79ec8bb3d412fb1f2d59a3767248a">Length of the request body. The unit is byte.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.3 "><p id="mrs_02_0008__a9815cc0accf94167b7f3607db7b90880">This field is mandatory for POST and PUT requests, but must be left blank for GET requests.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.4 "><p id="mrs_02_0008__af6f5766e2ad548dcb9e40b3a0074c125">3495</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__r47347abb1c994c38bacebe25ec1d218e"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.1 "><p id="mrs_02_0008__ab8ee25b819d94be08bf7cabf1d921b9a">X-Project-Id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.2 "><p id="mrs_02_0008__af63b53a9158e418c9317dd79ddcac3db">Project ID. This field is used to obtain the token for each project.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.3 "><p id="mrs_02_0008__a234f4a7f440b4413b1aa19c9462695ab">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.4 "><p id="mrs_02_0008__a148d7ff92e5e49cfbb4ac0238cd2ebd4">e9993fc787d94b6c886cbaa340f9c0f4</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__rbec1d01d1f9b4bcb8a183ded144e2f0a"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.1 "><p id="mrs_02_0008__a5ad0cfc3781243c9ac6fd8e5c47b8894">X-Auth-Token</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.2 "><p id="mrs_02_0008__a399eb5e20970416186d95d614e84af10">User token.</p>
|
|
<p id="mrs_02_0008__p1499864363419">It is the 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 request authentication</a>. This API is the only one that does not require authentication.</p>
|
|
<p id="mrs_02_0008__p18998543163416">The token is the value of <strong id="mrs_02_0008__b1429211919265">X-Subject-Token</strong> in the response header.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.3 "><p id="mrs_02_0008__a8ef6da5c4a3742a0b50adb96d3a52baf">No</p>
|
|
<p id="mrs_02_0008__a90d30c52a285436c8efb6b0924bc3912">This field is mandatory for token-based authentication.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.4 "><p id="mrs_02_0008__ac1a9d7862596407ba9dc5ca0dfa508c8">-</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__row16125640113240"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.1 "><p id="mrs_02_0008__p31108482113240">X-Language</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.2 "><p id="mrs_02_0008__p36759104113240">Request language. The options are as follows:</p>
|
|
<p id="mrs_02_0008__p64011575337"><strong id="mrs_02_0008__b1949891720345">en-us</strong>: English</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.3 "><p id="mrs_02_0008__p24697451113240">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.4 "><p id="mrs_02_0008__p54336490113240">en-us</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_02_0008__row1305912154611"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.1 "><p id="mrs_02_0008__p59561232104612">X-Domain-Id</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.2 "><p id="mrs_02_0008__p33051712144616">Domain ID</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.4.2.5.1.3 "><p id="mrs_02_0008__p2305312124612">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="30%" headers="mcps1.3.4.4.2.5.1.4 "><p id="mrs_02_0008__p193051912134613">-</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="note" id="mrs_02_0008__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="mrs_02_0008__en-us_topic_0121682347_p1513412221808">In addition to supporting token-based authentication, APIs also support authentication using access key ID/secret access key (AK/SK). During AK/SK-based authentication, an SDK is used to sign the request, and the <strong id="mrs_02_0008__b19411185110357">Authorization</strong> (signature authentication) and <strong id="mrs_02_0008__b44121851123510">X-Sdk-Date</strong> (time when the request is sent) header fields are automatically added to the request.</p>
|
|
<p id="mrs_02_0008__en-us_topic_0121682347_p1577123365010">For more information, see <strong id="mrs_02_0008__b24133612348">AK/SK-based Authentication</strong> in <a href="mrs_02_0009.html">Authentication</a>.</p>
|
|
</div></div>
|
|
<p id="mrs_02_0008__en-us_topic_0121682347_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="mrs_02_0008__parmname1437395818157"><b>Content-Type</b></span> field needs to be added to requests for calling the API. An example of such requests is as follows:</p>
|
|
<pre class="screen" id="mrs_02_0008__en-us_topic_0121682347_screen73731462616">POST https://{{endpoint}}/v3/auth/tokens
|
|
Content-Type: application/json</pre>
|
|
</div>
|
|
<div class="section" id="mrs_02_0008__en-us_topic_0121682347_en-us_topic_0113746487_section1437471411"><h4 class="sectiontitle">(Optional) Request Body</h4><p id="mrs_02_0008__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="mrs_02_0008__b1324710469569">Content-Type</strong> header field. The request body transfers content except the request header.</p>
|
|
<p id="mrs_02_0008__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="mrs_02_0008__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="mrs_02_0008__i334646192818">username</em>, <em id="mrs_02_0008__i1825925117284">domainname</em>, <em id="mrs_02_0008__i677556202811">********</em> (login password), and <em id="mrs_02_0008__i88034213293">xxxxxxxxxxxxxxxxxx</em> <em id="mrs_02_0008__i943351982618">(project ID)</em> with the actual values. To learn how to obtain a project ID, see <a href="mrs_02_0011.html">Obtaining a Project ID</a>.</p>
|
|
<div class="note" id="mrs_02_0008__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="mrs_02_0008__en-us_topic_0121682347_p199011223194814">The <strong id="mrs_02_0008__b13327144712299">scope</strong> parameter specifies where a token takes effect. You can set <strong id="mrs_02_0008__b1991919402188">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> of the IAM service.</p>
|
|
</div></div>
|
|
<pre class="screen" id="mrs_02_0008__en-us_topic_0121682347_screen6140617194816">POST https://{{endpoint}}/v3/auth/tokens
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"auth": {
|
|
"identity": {
|
|
"methods": [
|
|
"password"
|
|
],
|
|
"password": {
|
|
"user": {
|
|
"name": "<em id="mrs_02_0008__en-us_topic_0121682347_i315217719194"><strong id="mrs_02_0008__en-us_topic_0121682347_b14500116161919">username</strong></em>",
|
|
"password": "<strong id="mrs_02_0008__en-us_topic_0121682347_b2559181251918"><em id="mrs_02_0008__en-us_topic_0121682347_i12803128192">********</em></strong>",
|
|
"domain": {
|
|
"name": "<em id="mrs_02_0008__en-us_topic_0121682347_i1560271681911"><strong id="mrs_02_0008__en-us_topic_0121682347_b17173191614194">domainname</strong></em>"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"scope": {
|
|
"project": {
|
|
"id": "<strong id="mrs_02_0008__en-us_topic_0121682347_b1261200101711"><em id="mrs_02_0008__en-us_topic_0121682347_i186128061711">xxxxxxxxxxxxxxxxxx</em></strong>"
|
|
}
|
|
}
|
|
}
|
|
}</pre>
|
|
<p id="mrs_02_0008__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="mrs_02_0008__b147919263312">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="mrs_02_0002.html">Calling APIs</a></div>
|
|
</div>
|
|
</div>
|
|
|