2

I'm trying to create a new enterprise using api method. First I maked signupUrls.create with request parameters projectId and callbackUrl. In field callbackUrl, I put my Google Cloud platform admin url. And I got a response

{
  "name": "signupUrls/C78787fa85be23de9f",
  "url": "https://play.google.com/work/adminsignup?token=SAEQ6V4kHngQPk5wCSl37KkZPlfw-wJtlVHndDfsmH1R1twiXM1LC6FpYFSndpEaw2mbsmqd3T5eBaRWtQPrVClngJHZcKaGc0V_4dOhz-F8D0vSjb_1MnxRheUP0Ij8el6zNE5GYYA1LOECCUFLip8kcg6e99_3DfNbmutqHONjhdi8hQBQUa0Q5nWN-nMRF3EUgffvLk1zo4BAA0AUscQ"
}

The next point is method: enterprises.create with projectId, signupUrlName and enterpriseToken parameters.

And then I send request I get erorr:

"message": "The enterprise token is invalid: SAEQ6V4kHngQPk5wCSl37KkZPlfw-wJtlVHndDfsmH1R1twiXM1LC6FpYFSndpEaw2mbsmqd3T5eBaRWtQPrVClngJHZcKaGc0V_4dOhz-F8D0vSjb_1MnxRheUP0Ij8eCUFLip8kcg6e99_3DfNbmutqHONjhdi8hQBQUa0Q5nWN-nMRF3EUgffBWwGHSA8AkFWvLk1zo4BAA0AUscQ",
    "status": "INVALID_ARGUMENT"

In the field enterpriseToken I put token values from signupUrls.create url response.

Fred
  • 2,191
  • 1
  • 12
  • 14
Jekson
  • 2,892
  • 8
  • 44
  • 79

1 Answers1

4

To obtain the enterpriseToken you (or your customer) need to go through the enterprise sign-up flow by visiting the url returned by signupUrls.create, which looks like https://play.google.com/work/adminsignup?token=... (the token in this URL is not the enterpriseToken).

Upon completing the sign-up flow you will be redirected to the callbackUrl passed in signupUrls.create, with the enterpriseToken appended as a parameter. So if you set the callbackUrl to https://example.com/mycallback you will be redirected to a URL like https://example.com/mycallback?enterpriseToken=....

You then need to extract the enterpriseToken and pass it to enterprises.create.

So if you create the enterprise yourself you can set any callbackUrl, even an invalid one, and just copy the enterpriseToken manually. However if you want your customer to create the enterprise then the callbackUrl should point to your server so you can retrieve the enterpriseToken, you may also want to pass an additional token in the callbackUrl so you can identify your customer.

More details in the guide for creating an enterprise.

Fred
  • 2,191
  • 1
  • 12
  • 14
  • Thanks, successfully created a new enterprise. Could you tell me is there some kind of admin control panel where I can view and manage devices? – Jekson Mar 13 '19 at 08:21
  • 1
    Glad it worked. There is no console for the Android Management API, this API is meant to be called by EMMs (device management service providers) who are building their own console. If you would like to use an EMM you can browse the [list on the Android Enterprise website](https://androidenterprisepartners.withgoogle.com/emm/). Using an EMM solution is simpler than using the API directly, but on the flip side it's also less flexible and usually isn't free. – Fred Mar 13 '19 at 15:38
  • Hi @Fred Using Android Management API is free or is there any pricing attached to it ? Also is how we can created multiple enterprises as the default Android Management support only 1000 devices? – Ankur Oct 24 '19 at 14:03
  • Android Management API is free. To go beyond the quota of 1000 devices / project, just [join the EMM community](https://developers.google.com/android/management/join). – Fred Oct 24 '19 at 17:54
  • hello @Ankur can you tell me where you found out that AMAPI supports only 1000 devices. – CHIRAG SAHU Dec 30 '22 at 07:26
  • Documentation and comment from Fred confirmed that. – Ankur Dec 30 '22 at 20:36
  • hi @Fred I've try to create the enterprise android management api in web application, i need eneterprisetoken, but that have only generate code and scopes not in enterpriseToken my callback URL having https://example.com/mycallback?code=`redirectcode`&scopes=https://www.googleapis.com/auth/androidmanagement could you please provide any relevant solutions – R sukumar May 20 '23 at 14:46