Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Apps Admin SDK Directory API 403 in PHP
    primarykey
    data
    text
    <p>I'm getting </p> <pre><code> Error calling GET https://www.googleapis.com/admin/directory/v1/users/email@example.com.com: (403) Not Authorized to access this resource/api </code></pre> <p>when running</p> <pre><code> $client = new Google_Client(); $client-&gt;setClientId(GOOGLEAPPS_CLIENT_ID); $client-&gt;setApplicationName(SITE_NAME); $key = file_get_contents(APPLICATION_PATH . 'googleapps-privatekey.p12'); $assertion = new Google_AssertionCredentials( GOOGLEAPPS_EMAIL_ADDRESS, // the service account name array('https://www.googleapis.com/auth/admin.directory.user'), // see https://developers.google.com/admin-sdk/directory/v1/guides/authorizing $key); $client-&gt;setAssertionCredentials($assertion); $service = new Google_DirectoryService($client); $user = $service-&gt;users-&gt;get('email@example.com'); </code></pre> <p>I followed the instructions <a href="https://developers.google.com/admin-sdk/directory/v1/guides/prerequisites" rel="nofollow">https://developers.google.com/admin-sdk/directory/v1/guides/prerequisites</a> and ticked Enable API Access. I used the Google APIs console <a href="https://code.google.com/apis/console" rel="nofollow">https://code.google.com/apis/console</a> to generate a Service Account key and got that working OK. </p> <p><a href="https://groups.google.com/forum/#!msg/google-api-php-client/LM-mwmuZe7I/IA_K5v1R1UMJ" rel="nofollow">https://groups.google.com/forum/#!msg/google-api-php-client/LM-mwmuZe7I/IA_K5v1R1UMJ</a></p> <p>I used the Google PHP library and followed the instructions <a href="https://code.google.com/p/google-api-php-client/wiki/OAuth2?hl=no#Service_Accounts" rel="nofollow">https://code.google.com/p/google-api-php-client/wiki/OAuth2?hl=no#Service_Accounts</a> to try and get service accounts working. Debugging into their code: I'm authorising fine and getting a fresh Access token as expected <a href="https://developers.google.com/accounts/docs/OAuth2ServiceAccount" rel="nofollow">https://developers.google.com/accounts/docs/OAuth2ServiceAccount</a>.</p> <p>I can't figure out why I'm getting the "Not Authorized to access this resource/api" message when everything I have read says I've switched it all on OK. Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload