See api-docs Menu

Set Password by ID Using Cleartext

Initially set or subsequently change a user’s password.

Note that setting a user password using cleartext via this API is comparable to using our in-browser, form-based Set Password functionality on top of an encrypted channel.

Resource URL

https://api.<us_or_eu>.onelogin.com/api/1/users/
set_password_clear_text/:id

Header Parameters

Authorization

required

String

Set to bearer:<access_token>.

Set <access_token> to the access token you generated using the Generate Token API.

The access token must have been generated using an API credential pair created using the scope required to call this API. This API can be called using the Manage All scope only.

Content-Type

required

String

Set to application/json.

Resource Parameter

id

required

Integer

Set to the id of the user for which you want to set or reset a password. If you don’t know the user’s id, use the Get Users API call to return all users and their id values.

Request Parameters

password

required

String

Set to the password value using cleartext.

Hashes are never stored as cleartext. They are stored securely using cryptographic hash. OneLogin continuously upgrades the strength of the hash. Ensure that the value meets the password strength requirements set for the account.

password_confirmation

 required

String

Ensure that this value matches the password value exactly.

Sample Request Body

{
   "password":"{password_value}",
   "password_confirmation":"{password_value}"
}

Sample Response

{
    "status": {
        "error": false,
        "code": 200,
        "type": "success",
        "message": "Success"
 }
}

Here are a few different errors that will return a 400 Bad Request status code.

{
  "status": {
    "error": true,
    "code": 400,
    "type": "bad request",
    "message": {
      "attribute": "id",
      "description": "ID is incorrect"
    }
 }
}

Typically, the following error means that the Authorization header is missing or incorrectly formatted. The Authorization header should use this format: bearer:<access_token>.

{
    "status": {
        "error": true,
        "code": 400,
        "type": "bad request",
        "message": "Authorization Information is incorrect"
 }
}

{
    "status": {
        "error": true,
        "code": 400,
        "type": "bad request",
        "message": "Content Type is not specified or specified incorrectly. 
                    Content-Type header must be set to application/json"
 }
}

{
    "status": {
        "error": true,
        "code": 400,
        "type": "bad request",
        "message": "password and password_confirmation must be same"
    }
}

{
    "status": {
        "error": true,
        "code": 400,
        "type": "bad request",
        "message": "setting password requires these parameters => password 
                    password_confirmation "
    }
}

{
    "status": {
        "error": true,
        "code": 400,
        "type": "bad request",
        "message": "Input JSON is not valid"
    }
}

Typically, the following error means that the access token used to make the call was generated using API credentials that have insufficient permissions. This API can be called using the Manage All scope only.

{
    "status": {
        "error": true,
        "code": 401,
        "type": "Unauthorized",
        "message": "Insufficient Permission"
 }
}

Typically, the following error means that the access token is invalid.

{
    "status": {
        "error": true,
        "code": 401,
        "type": "Unauthorized",
        "message": "Authentication Failure"
 }
}
{
    "status": {
        "error": true,
        "code": 403,
        "type": "forbidden",
        "message": "user is not authorized to access this User"
 }
}
{
  "status": {
    "error": true,
    "code": 404,
    "type": "not found",
    "message": "User for id 9999999999999999 was not found"
 }
}

Postman Collection

Replace sample variables indicated by < > in the sample request body with your actual values. Also, be sure to set Postman-specific environment variables indicated by {{ }}.

Download for the Users API

Sample Code

cURL

Replace sample values indicated by < > with your actual values.

curl 'https://api.<us_or_eu>.onelogin.com/api/1/users/set_password_clear_text/<id>' \
-X PUT \
-H "Authorization: bearer:<access_token>" \
-H "Content-Type: application/json" \
-d '{
    "password":"<password>",
    "password_confirmation":"<password_confirmation>"
}' 

Python

See Work with OAuth 2.0 Tokens, Users, and Roles.


Have a Question?

Have a how-to question? Seeing a weird error? Ask us about it on StackOverflow.

Found a bug? Submit a support ticket.

Have a product idea or request? Share it with us in our Ideas Portal.