Issuecommand RESET_PASSWORD on android management api doesn't change lock code of the device et LOCK_NOW flag doesn't lock the device either

Viewed 162
2 Answers

Does anyone find any solution ? I have the same problem with this command :

I find the command in the documentation.

When i execute this CURL, it answer me 200 OK.

curl --location --request POST 'https://androidmanagement.googleapis.com/v1/enterprises/<enterprise>/devices/<device_id>:issueCommand' \
--header 'content-type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data-raw '{
    "type": "RESET_PASSWORD",
    "duration": "600s"
}'
{
    "name": "enterprises/<enterprise>/devices/<device_id>/operations/<operation_id>",
    "metadata": {
        "@type": "type.googleapis.com/google.android.devicemanagement.v1.Command",
        "type": "RESET_PASSWORD",
        "createTime": "2022-05-03T09:34:15.913Z",
        "duration": "600s",
        "userName": "enterprises/<enterprise>/users/<user_id>"
    }
}

But, when i try to get the health of the operation, it answer to me an error:

curl --location --request GET 'https://androidmanagement.googleapis.com/v1/enterprises/<enterprise>/devices/<device_id>/operations/<operation_id>' \
--header 'content-type: application/json' \
--header 'Authorization: Bearer <TOKEN>'

Answer (200 OK):

{
    "name": "enterprises/<enterprise>/devices/<device_id>/operations/<operation_id>",
    "metadata": {
        "@type": "type.googleapis.com/google.android.devicemanagement.v1.Command",
        "type": "RESET_PASSWORD",
        "createTime": "2022-05-03T09:34:15.913Z",
        "duration": "600s",
        "errorCode": "INVALID_VALUE",
        "userName": "enterprises/<enterprise>/users/<user_id>"
    },
    "done": true,
    "error": {
        "code": 3
    }
}

i don't know which invalid value i put into the params..

More, the LOCK or REBOOT command work correctly without any error for the same device.

Sincerely.

Adrien.

I tried to recreate the scenario using the same settings that you are using and I was able to reset my password and change it to the new password.

device_name = enterprise_name + '/devices/deviceId'
 
device_json = '''
{
  "duration": "600s",
  "type": "RESET_PASSWORD",
  "newPassword": "12345",
  "resetPasswordFlags": [
    "LOCK_NOW"
  ]
}
'''
 
androidmanagement.enterprises().devices().issueCommand(
    name=device_name,
    body=json.loads(device_json)
).execute()

This API seems to be working properly in my end. For this API to work properly, please make sure the newPassword value meets any passwordRequirements you have set in the policy. Also, you can check the device if it receives the command as it should lock its screen automatically upon receiving the command.

You can also try using other commands to ensure that the issue is not in your device or connection.

Related