0
votes

I've been getting a HTTP 403 error when trying to call the 'Create a user account' operation with the Provisioning API (via POST @ https://apps-apis.google.com/a/feeds/domain/user/2.0). The response received is a 403 error:

"error": {
  "errors": [
   {
    "domain": "global",
    "reason": "forbidden",
    "message": "Forbidden"
   }
  ],
  "code": 403,
  "message": "Forbidden"
 }
}

The API had been working until late last week. No code was changed in my codebase. Is the API down? The API docs does say the API has been deprecated. But the API should still working per their Deprecation Policy.

EDIT: So it seems the Provisioning API has been replaced by the Directory API. And in the Directory API prerequisites, it says"

Note: The API device operations do not support remote administrative access for Google authorized resellers.

Does that mean the same thing for Provisioning API? Meaning, administrative access such as API for Creating Users cannot be accessed by the Google Authorized resellers?

1

1 Answers

0
votes

I know this question is a bit outdated, but as it goes without answer and I've spent a few hours trying to figure this out today, it seems my answer can come to help somebody in the future.

The problem with my code was: I was trying to log in with the user's account data (username + password). I've created another account with administrative privileges to proceed to the update.

The solution in my case looks like this:

$domain = 'yourdomain.com';
$username = '...';       // the user you're trying to update
$admin_username = '...'; // administrative credentials
$admin_password = '...';


$config = array(
              'adapter' => 'Zend_Http_Client_Adapter_Proxy',
              'proxy_host' => 'proxy.example.com',
              'proxy_port' => '...'); // your proxy port here (ex: 8000)

$proxiedHttpClient = new Zend_Gdata_HttpClient(
                             'https://www.google.com:443',
                             $config);

$client = Zend_Gdata_ClientLogin::getHttpClient(
              $admin_username,
              $admin_password,
              Zend_Gdata_Gapps::AUTH_SERVICE_NAME,
              $proxiedHttpClient);

$gdata = new Zend_Gdata_Gapps($client, $domain);
$userEntry = $gdata->retrieveUser($username);

// example: changing user's password
$userEntry->getLogin()->setPassword('Top$EcreT_2014');


$gdata->updateUser($username, $userEntry);