'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
I'm trying to reset the lock code of my device through android management API but it seems that RESET_PASSWORD doesn't do anything. The endpoint is https://androidmanagement.googleapis.com/v1/enterprises/entrepriseID/devices/deviceID:issueCommand and my payload looks like this
{
"type": "RESET_PASSWORD" ,
"duration": "600s",
"newPassword":"1234",
"resetPasswordFlags":["LOCK_NOW"]
}
Solution 1:[1]
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.
Solution 2:[2]
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 double-check your target deviceId if correct. 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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | rsiason |