Programmatically Add Domain Alias google apps api

2019-08-31 08:44发布

问题:

I have a reseller account with Google Apps For Business. I am using the google-api-php-client SDK for PHP from the GitHub repository:

https://github.com/google/google-api-php-client

I have already created the customer account as a reseller. I have verified the primary domain using the site verification service. I am trying to add a domain alias to the primary domain for the customers account. I am not seeing any documentation for this process in the API. I know how to do this using the admin panel. I also know how to add an alias for the users email, however, I do not want a user alias because I will be migrating hundreds of email accounts and need the domain alias.

Does anyone know of how to accomplish this using the above API or use a custom request?

If this question is too vague please let me know.

回答1:

None such option exists in the current Admin SDK or the Reseller API.



回答2:

Assuming there are no restrictions on a reseller account that would prevent it, you can manage DomainAliases including adding and alias through the Directory API using the following post request (replacing 'myalias.com' and 'parentdomain.com' with your values; you will need to include your authorization token Authorization header).

POST https://www.googleapis.com/admin/directory/v1/customer/my_customer/domainaliases

Authorization: Bearer xxx-token-xxx
Content-Type: application/json

{
 "domainAliasName": "myalias.com",
 "parentDomainName": "parentdomain.com"
}

The documentation for this API method includes the APIs Explorer providing a convenient form for test this API call. When completing the form on this page, enter 'my_customer' in the customer field.