Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle OAuth2 Service Accounts API Authorization
    primarykey
    data
    text
    <p>I'm trying to authenticate my server app through Google's service account authentication but, for some reason, it is just not pushing through.</p> <p>In the <a href="https://code.google.com/apis/console/" rel="nofollow">API console</a>, I already created the project, enabled the service I need (Admin SDK), and created a Service Account and Web Application API Access.</p> <p>When I do use the web application access credentials I am able to authenticate and retrieve user records. But using service account authentication would keep giving me a login required message.</p> <pre><code>"error": { "errors": [ { "domain": "global", "reason": "required", "message": "Login Required", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Login Required" } </code></pre> <p>I forgot to add, I am testing this with the PHP client library.</p> <pre><code>public function init() { $client = new Google_Client(); if (isset($_SESSION['access_token'])) { $client-&gt;setAccessToken($_SESSION['access_token']); } $key = file_get_contents(App::SERVICE_KEY_FILE); $client-&gt;setAssertionCredentials(new Google_AssertionCredentials( App::SERVICE_ACCOUNT_NAME, App::SERVICE_API_SCOPES, $key) ); $client-&gt;setClientId(App::SERVICE_CLIENT_ID); debug($client, 'CLIENT'); if ($client-&gt;getAccessToken()) { $this-&gt;access_token = $_SESSION['access_token'] = $client-&gt;getAccessToken(); debug($_SESSION['access_token'], 'TOKEN'); } else { debug('NO TOKEN'); } $this-&gt;client = $client; } </code></pre> <p>As you can see, the code is basically about the same as the Google example. Am I missing an extra step?</p> <p>One last thing, when I authenticate using the web app then access my service account script, the service account script can pick up the web app script's session and push through with the user record retrievals. Does that mean the Admin SDK API explicitly needs user interaction through web app authentication?</p>
    singulars
    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.
    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