doc-exports/docs/iam/api-ref/en-us_topic_0057845653.html
zhangyue 3b5a58b1fe IAM API 2.0.38
Reviewed-by: gtema <artem.goncharov@gmail.com>
Co-authored-by: zhangyue <zhangyue164@huawei.com>
Co-committed-by: zhangyue <zhangyue164@huawei.com>
2022-10-26 04:31:24 +00:00

175 lines
16 KiB
HTML

<a name="en-us_topic_0057845653"></a><a name="en-us_topic_0057845653"></a>
<h1 class="topictitle1">Changing a Password</h1>
<div id="body1492670576072"><div class="section" id="en-us_topic_0057845653__s5888597838b0425a92e3419fb766c7f5"><h4 class="sectiontitle">Function</h4><p id="en-us_topic_0057845653__p207718521847">This API is used to change the password for a user.</p>
</div>
<div class="section" id="en-us_topic_0057845653__s46d3616bd4c54e55ba97a528518a5890"><h4 class="sectiontitle">URI</h4><ul id="en-us_topic_0057845653__en-us_topic_0026585112_ul20917673"><li id="en-us_topic_0057845653__l0762c927197248c39057087e143d6575">URI format<p id="en-us_topic_0057845653__p16330458113837"><a name="en-us_topic_0057845653__l0762c927197248c39057087e143d6575"></a><a name="l0762c927197248c39057087e143d6575"></a>POST /v3/users/{user_id}/password</p>
</li><li id="en-us_topic_0057845653__li32682147113817">URI parameters
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="en-us_topic_0057845653__en-us_topic_0032920337_table29648085" frame="border" border="1" rules="all"><thead align="left"><tr id="en-us_topic_0057845653__en-us_topic_0032920337_row12693918"><th align="left" class="cellrowborder" valign="top" width="21.68%" id="mcps1.3.2.2.2.1.1.5.1.1"><p id="en-us_topic_0057845653__en-us_topic_0032920337_p21574462"><strong id="en-us_topic_0057845653__a6f95694edbbb43d8a152536754b86c82">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="21.55%" id="mcps1.3.2.2.2.1.1.5.1.2"><p id="en-us_topic_0057845653__en-us_topic_0032920337_p2701015"><strong id="en-us_topic_0057845653__a105e6ed8c3de4c5a9dde97ae5a71071e_1">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20.22%" id="mcps1.3.2.2.2.1.1.5.1.3"><p id="en-us_topic_0057845653__en-us_topic_0032920337_p17455632"><strong id="en-us_topic_0057845653__a703d34a49a2f4162bc1a1a439f655f95_1">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="36.55%" id="mcps1.3.2.2.2.1.1.5.1.4"><p id="en-us_topic_0057845653__en-us_topic_0032920337_p4620049"><strong id="en-us_topic_0057845653__b842352706114032_1">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0057845653__en-us_topic_0032920337_row38679683"><td class="cellrowborder" valign="top" width="21.68%" headers="mcps1.3.2.2.2.1.1.5.1.1 "><p id="en-us_topic_0057845653__en-us_topic_0032920337_p46046605">user_id</p>
</td>
<td class="cellrowborder" valign="top" width="21.55%" headers="mcps1.3.2.2.2.1.1.5.1.2 "><p id="en-us_topic_0057845653__en-us_topic_0032920337_p38787544">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20.22%" headers="mcps1.3.2.2.2.1.1.5.1.3 "><p id="en-us_topic_0057845653__en-us_topic_0032920337_p54783372">String</p>
</td>
<td class="cellrowborder" valign="top" width="36.55%" headers="mcps1.3.2.2.2.1.1.5.1.4 "><p id="en-us_topic_0057845653__en-us_topic_0032920337_p8268111">User ID.</p>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
</div>
<div class="section" id="en-us_topic_0057845653__se7fe5cac0d544e119c49322cc1707eb6"><h4 class="sectiontitle">Request Parameters</h4><ul id="en-us_topic_0057845653__en-us_topic_0026585112_ul3226198"><li id="en-us_topic_0057845653__l7c4919f55ea849a9bb59e1454113085c">Parameters in the request header
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="en-us_topic_0057845653__t68c7bd10e66a4380a1e6cdc78ca95669" frame="border" border="1" rules="all"><thead align="left"><tr id="en-us_topic_0057845653__r584496594a404ce18918a40e6e57c2ec"><th align="left" class="cellrowborder" valign="top" width="21.68%" id="mcps1.3.3.2.1.1.1.5.1.1"><p id="en-us_topic_0057845653__ac3a989cc5d3a405889eabb47dee84b04"><strong id="en-us_topic_0057845653__b908709152145847">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="21.68%" id="mcps1.3.3.2.1.1.1.5.1.2"><p id="en-us_topic_0057845653__a69a20ac00b86496aa8418517c542b0da"><strong id="en-us_topic_0057845653__a105e6ed8c3de4c5a9dde97ae5a71071e_3">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20.06%" id="mcps1.3.3.2.1.1.1.5.1.3"><p id="en-us_topic_0057845653__a92c23d4441054df0972e025aeb3a8d7f"><strong id="en-us_topic_0057845653__a703d34a49a2f4162bc1a1a439f655f95_3">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="36.58%" id="mcps1.3.3.2.1.1.1.5.1.4"><p id="en-us_topic_0057845653__abe6882c44cf4402d8ed7706b9278f33b"><strong id="en-us_topic_0057845653__b33386045145854">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0057845653__r5d63069d6a8a426e8b25b94d1b4d302a"><td class="cellrowborder" valign="top" width="21.68%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="en-us_topic_0057845653__ad4fb6253385c46ab8720a0e13f573694">Content-Type</p>
</td>
<td class="cellrowborder" valign="top" width="21.68%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="en-us_topic_0057845653__a6b33800bcb2a446695b1d33a2d751554">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20.06%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="en-us_topic_0057845653__ab34a5e95b76b4b79a72da0734025f211">String</p>
</td>
<td class="cellrowborder" valign="top" width="36.58%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="en-us_topic_0057845653__a716277ae541d4553bb10490f9c02593d">Fill <strong id="en-us_topic_0057845653__b842352706161331">application/json;charset=utf8</strong> in this field.</p>
</td>
</tr>
<tr id="en-us_topic_0057845653__row29501427115257"><td class="cellrowborder" valign="top" width="21.68%" headers="mcps1.3.3.2.1.1.1.5.1.1 "><p id="en-us_topic_0057845653__p6637478211538">X-Auth-Token</p>
</td>
<td class="cellrowborder" valign="top" width="21.68%" headers="mcps1.3.3.2.1.1.1.5.1.2 "><p id="en-us_topic_0057845653__p764826811538">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="20.06%" headers="mcps1.3.3.2.1.1.1.5.1.3 "><p id="en-us_topic_0057845653__p1553001111538">String</p>
</td>
<td class="cellrowborder" valign="top" width="36.58%" headers="mcps1.3.3.2.1.1.1.5.1.4 "><p id="en-us_topic_0057845653__p4997141111538">Authenticated token.</p>
</td>
</tr>
</tbody>
</table>
</div>
</li><li id="en-us_topic_0057845653__en-us_topic_0026585112_li29035785">Parameters in the request body
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="en-us_topic_0057845653__en-us_topic_0026585112_table59995477" frame="border" border="1" rules="all"><thead align="left"><tr id="en-us_topic_0057845653__en-us_topic_0026585112_row14620943"><th align="left" class="cellrowborder" valign="top" width="21.61%" id="mcps1.3.3.2.2.1.1.5.1.1"><p id="en-us_topic_0057845653__en-us_topic_0026585112_p43445707"><strong id="en-us_topic_0057845653__b5942968917213">Parameter</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="21.81%" id="mcps1.3.3.2.2.1.1.5.1.2"><p id="en-us_topic_0057845653__en-us_topic_0026585112_p29441404"><strong id="en-us_topic_0057845653__a105e6ed8c3de4c5a9dde97ae5a71071e_5">Mandatory</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="19.950000000000003%" id="mcps1.3.3.2.2.1.1.5.1.3"><p id="en-us_topic_0057845653__en-us_topic_0026585112_p35943562"><strong id="en-us_topic_0057845653__a703d34a49a2f4162bc1a1a439f655f95_5">Type</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="36.63%" id="mcps1.3.3.2.2.1.1.5.1.4"><p id="en-us_topic_0057845653__en-us_topic_0026585112_p25747420"><strong id="en-us_topic_0057845653__b4702773417213">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0057845653__row15919216102748"><td class="cellrowborder" valign="top" width="21.61%" headers="mcps1.3.3.2.2.1.1.5.1.1 "><p id="en-us_topic_0057845653__p14388120102748">original_password</p>
</td>
<td class="cellrowborder" valign="top" width="21.81%" headers="mcps1.3.3.2.2.1.1.5.1.2 "><p id="en-us_topic_0057845653__p24587085102748">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="19.950000000000003%" headers="mcps1.3.3.2.2.1.1.5.1.3 "><p id="en-us_topic_0057845653__p45396854102748">String</p>
</td>
<td class="cellrowborder" valign="top" width="36.63%" headers="mcps1.3.3.2.2.1.1.5.1.4 "><p id="en-us_topic_0057845653__p53266556102748">Original password of a user.</p>
</td>
</tr>
<tr id="en-us_topic_0057845653__row12436720103234"><td class="cellrowborder" valign="top" width="21.61%" headers="mcps1.3.3.2.2.1.1.5.1.1 "><p id="en-us_topic_0057845653__p741379103234">password</p>
</td>
<td class="cellrowborder" valign="top" width="21.81%" headers="mcps1.3.3.2.2.1.1.5.1.2 "><p id="en-us_topic_0057845653__p60051710103234">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="19.950000000000003%" headers="mcps1.3.3.2.2.1.1.5.1.3 "><p id="en-us_topic_0057845653__p32350346103234">String</p>
</td>
<td class="cellrowborder" valign="top" width="36.63%" headers="mcps1.3.3.2.2.1.1.5.1.4 "><div class="p" id="en-us_topic_0057845653__p60772195174811">User password after the change. The password must meet the following requirements:<ul id="en-us_topic_0057845653__ul62058101036"><li id="en-us_topic_0057845653__li558522971036">Can contain 6 to 32 characters. The default minimum password length is 6 characters.</li><li id="en-us_topic_0057845653__li277421951036">Must contain at least two of the following character types: uppercase letters, lowercase letters, digits, and special characters.</li><li id="en-us_topic_0057845653__li1223513894319">Cannot be the username or the username spelled backwards.</li><li id="en-us_topic_0057845653__li483531691036">Cannot contain the user's mobile phone number or email address.</li><li id="en-us_topic_0057845653__li325253421036">Must meet the requirements of the password policy configured on the account settings page.</li></ul>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</li><li id="en-us_topic_0057845653__en-us_topic_0026585112_li17042198">Example request<pre class="screen" id="en-us_topic_0057845653__s6b85ed1428f745fabd2d60e4481ee1db">1. Create the temporary file <em id="en-us_topic_0057845653__i975925214468">${filename}</em><strong id="en-us_topic_0057845653__b975985284610">.json</strong> based on the following template. <em id="en-us_topic_0057845653__i177592052184613">${filename} </em>indicates the temporary file name, which is user-defined.
{
"user": {
"password": "********",
"original_password": "********"
}
}
2. Run the following command under the directory storing the <em id="en-us_topic_0057845653__i2199144113207">${filename}</em>.<strong id="en-us_topic_0057845653__b8205141102010">json</strong> file.
<em id="en-us_topic_0057845653__i195976413240">curl -i -k -H 'Accept:application/json' -H 'Content-Type:application/json;charset=utf8' -H "X-Auth-Token:$token" -X POST -d @${filename}.json </em><em id="en-us_topic_0057845653__i17542122911521">https://sample.domain.com/v3/users/2c1c6c54e59141b889c99e6fada5f19f/password</em>
3. Run the following command under the directory of the <em id="en-us_topic_0057845653__i207618524463">${filename}</em><strong id="en-us_topic_0057845653__b147611052104617">.json</strong> file to delete the <em id="en-us_topic_0057845653__i1476125213463">${filename}</em><strong id="en-us_topic_0057845653__b117612523461">.json</strong> file.
<strong id="en-us_topic_0057845653__b16469439273">rm</strong> <em id="en-us_topic_0057845653__i14664314272">${filename}.json</em></pre>
</li></ul>
</div>
<div class="section" id="en-us_topic_0057845653__section1785605144015"><h4 class="sectiontitle">Response Parameters</h4><p id="en-us_topic_0057845653__p1685685124013">None</p>
</div>
<div class="section" id="en-us_topic_0057845653__section5539487417923"><h4 class="sectiontitle">Status Codes</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="en-us_topic_0057845653__en-us_topic_0035544336_table25927028" frame="border" border="1" rules="all"><thead align="left"><tr id="en-us_topic_0057845653__en-us_topic_0035544336_row10578662"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.5.2.1.3.1.1"><p id="en-us_topic_0057845653__en-us_topic_0035544336_p51565323"><strong id="en-us_topic_0057845653__b842352706104328">Status Code</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.5.2.1.3.1.2"><p id="en-us_topic_0057845653__en-us_topic_0035544336_p16041657"><strong id="en-us_topic_0057845653__b842352706114032_3">Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="en-us_topic_0057845653__en-us_topic_0035544336_row24305815"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.1 "><p id="en-us_topic_0057845653__en-us_topic_0035544336_p22613965">204</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.2 "><p id="en-us_topic_0057845653__en-us_topic_0035544336_p19791876">The password is changed successfully.</p>
</td>
</tr>
<tr id="en-us_topic_0057845653__en-us_topic_0035544336_row43909159"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.1 "><p id="en-us_topic_0057845653__en-us_topic_0035544336_p66980994">400</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.2 "><p id="en-us_topic_0057845653__en-us_topic_0035544336_p56751409">The server failed to process the request.</p>
</td>
</tr>
<tr id="en-us_topic_0057845653__rb99fbab78bc54ae4953661763b573830"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.1 "><p id="en-us_topic_0057845653__aef55745ff0834933af36d690e2e339b8">401</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.2 "><p id="en-us_topic_0057845653__a480215738ced4bf5a8feafa2681db93b">Authentication failed.</p>
</td>
</tr>
<tr id="en-us_topic_0057845653__en-us_topic_0035544336_row41000636"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.1 "><p id="en-us_topic_0057845653__en-us_topic_0035544336_p32717189">403</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.2 "><p id="en-us_topic_0057845653__ae678037f26d640f5a985c943e2ffb92e">Access denied.</p>
</td>
</tr>
<tr id="en-us_topic_0057845653__r1fd5c05b7b6b4c048f3f7b9ddbc755b0"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.1 "><p id="en-us_topic_0057845653__a5d7e2305922e4f9098442a900792dae1">404</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.2 "><p id="en-us_topic_0057845653__a9edf299d0513460caaac8a2a19b76e9a">The requested resource cannot be found.</p>
</td>
</tr>
<tr id="en-us_topic_0057845653__rbb5133f150fd42eebde8dd6e390ecbd5"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.1 "><p id="en-us_topic_0057845653__ad1a2754016e44193a97043265cd611cf">405</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.2 "><p id="en-us_topic_0057845653__a81837d461ef445259c5a6e9e1ce0e32a">The method specified in the request is not allowed for the requested resource.</p>
</td>
</tr>
<tr id="en-us_topic_0057845653__r2cecff297b1a412f956a312d3cd7acc9"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.1 "><p id="en-us_topic_0057845653__a1f617621d1bc4a9facb1c84d1946002b">413</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.2 "><p id="en-us_topic_0057845653__ac31ead3ee2db40eea8ae45b2779a09e9">The request entity is too large.</p>
</td>
</tr>
<tr id="en-us_topic_0057845653__rd71e0e00759f4179a2dccaf345ba9f2f"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.1 "><p id="en-us_topic_0057845653__a1657c5ca5ebd4a2cbacbdb35fc9b7601">500</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.2 "><p id="en-us_topic_0057845653__a88b4b14048564e12942b8151dc791b99">Internal server error.</p>
</td>
</tr>
<tr id="en-us_topic_0057845653__r5647e5fd26974514ac66cc3925f30601"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.1 "><p id="en-us_topic_0057845653__a16dfaa16ceac4a33a468c0ae158292fb">503</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.2.1.3.1.2 "><p id="en-us_topic_0057845653__a5635c1924d9648a8be89b1e5dcf0a87b">Service unavailable.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0057845593.html">User Management</a></div>
</div>
</div>