Reputation: 834
I'm trying to enroll a new device using the quickstart colab guide. I have successfully create an enterprise, a policy and an enrollment token. I can also successfully query those using the Android Management API.
However, enrollment is not working. Whenever I am scanning the associated QR code with a device, I get an "invalid code" (invalid code; the code you have provided isn't valid) message with the option to try again or to reset the device.
How can I debug this? Is there a way to find out more about why it is failing?
Upvotes: 2
Views: 1267
Reputation: 341
The token may have expired. You can actually set the duration of the token by setting the duration
field.
https://developers.google.com/android/management/reference/rest/v1/enterprises.enrollmentTokens#EnrollmentToken
Sample:
enrollment_token = androidmanagement.enterprises().enrollmentTokens().create(
parent=enterprise_name,
body={"policyName": policy_name,"duration":"864000s"}
).execute()
Also, you can scan the QR code to check its contents. It should match the content below, with your token value filled in:
{
"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME":"com.google.android.apps.work.clouddpc/.receivers.CloudDeviceAdminReceiver",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM":"I5YvS0O5hXY46mb01BlRjq4oJJGs2kuUcHvVkAPEXlg",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION":"https://play.google.com/managed/downloadManagingApp?identifier=setup",
"android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE":{
"com.google.android.apps.work.clouddpc.EXTRA_ENROLLMENT_TOKEN":"XXXXXXXXXXXXXXXXXXXX"
}
}
Upvotes: 1