Reputation: 1
I'm trying to create some automation to add users to a Google Play Developer account using the API. I wrote a python script using the google-api-python-client library. The service account I'm using for the request has admin rights. I've successfully used the users.list endpoint to get a list of users and the grants.create endpoint to grant app access to an existing account. But calling the users.create endpoint, I always get an error code 500 (Internal error encountered), unless I omit the email address from the User JSON object, in which case I get 400 (Email required).
userId = 'developers/' + DEVELOPER_ID + '/users/' + user["email"]
createUserRequestBody = {
'name': userId,
'email': user["email"]
}
createUserRequest = service.users().create(parent="developers/" + DEVELOPER_ID, body=createUserRequestBody)
createUserRequest.execute()
Following the documentation at https://developers.google.com/android-publisher/api-ref/rest/v3/users#User , I've tried sending only the email in the request body, as well as sending all fields not marked as "Output only" and sending every field including the ones marked "Output only". I've also tried using the Rest API directly instead of going through the python library. I'm always getting the same code 500. What am I missing? Has anyone been able to successfully create users using this API?
Edit: Printing the entire response object only gets me this:
<HttpError 500 when requesting https://androidpublisher.googleapis.com/androidpublisher/v3/developers/(developer ID)/users?alt=json returned "Internal error encountered.". Details: "Internal error encountered.">
Upvotes: 0
Views: 38
Reputation: 1
It turns out that the user.create endpoint doesn't accept an empty list of developerAccountPermissions. I tried not sending the parameter, sending an empty list, and sending DEVELOPER_LEVEL_PERMISSION_UNSPECIFIED since we don't want these users to have developer account access, but all of these cause the code 500 to be returned. Setting an actual developer account permission fixes the issue.
e.g.
createUserRequestBody = {'name': userId, 'email': user["email"], 'developerAccountPermissions': ["CAN_VIEW_FINANCIAL_DATA_GLOBAL"]}
Upvotes: 0