Question

I am trying to automate the entire process of creating a google apps account through my company's reseller account with google, without any human having to manually enable anything.

Here's a quick scenario of what I am doing.

  1. Create Customer (Domain) with Reseller API
  2. Create Subscription with Reseller API
  3. Create Admin Account for the Sold Domain

I am having trouble automating step 3.

There are 2 different APIs that can accomplish this tast, Provisioning (depricated) and Directory.

I have already successfully created user accounts with the Directory API, but this step requires you to enable API access for that domain, and that can only be done manually by a human - So thats a break in automation flow, and wont work for what I am trying to accomplish.

I was instructed by google tech support to use the Provisioning API, wich is deprecated, because it supposedly allows you to create an admin user without the need to enable the API access manually per domain. When I attempt to do this, I face this error:

Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 403 <HTML> <HEAD> <TITLE>You are not authorized to perform operations on the domain mydomain.com</TITLE>

Here's the code im attempting to run:

// .....

$customerid = "somedomain.com";

$client = Zend_Gdata_ClientLogin::getHttpClient("mylogin@foo.com", "mypassword",Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
$gdata = new Zend_Gdata_Gapps($client, $customerid);

$gdata->createUser('Admin', 'Firstname', 'Lastname', 'somerandompassword', TRUE);

//......

When I consulted google tech support, they told me I needed to enable the provisioning api following the same instruction I posted earlier (enable api access per domain). I have done this on both my reseller domain, and the customer domain Im trying to provision on (just to test, becasue the entire point is to be able to make an admin account WITHOUT enabling it on the customer domain.) - But it still returns this error.

Here's my settings -- as you can see, its enabled.

enter image description here

In google's docs, under "Enabling the Provisioning API", it has some instructions, but they appear to be out of date and dont really reflect sections available in the current google apps admin panel.

Im at a loss. Am I missing something obvious, or is it just not possible to do at this time?

Just for reference, I have found a few other people asking a similar question, but with less detail:

EDIT: Added image showing settings, and code sample.

Was it helpful?

Solution

try to delete "TRUE" parameter in createUser , it's works for me.

$customerid = "sampledomain.com";

$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
$gdata = new Zend_Gdata_Gapps($client, $customerid);

var_dump($gdata->createUser('trial', 'Firstname', 'Lastname', 'somerandompassword'));

OTHER TIPS

in Google app console domain settings ->user settings check the box "enable API access"

in Google app console --> advanced tools --> Manage third party OAuth Client access

Add the scope : https://apps-apis.google.com/a/feeds/user

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top