title: Service Applications and Google Analytics API V3: Server-to-server OAuth2 authentication?
body: <p>I'm trying to make a server application to routinely pull Google Analytics data from my own GA account. Note, it is a personal, server-side application accessing my own data, i.e. <em>there is no end-user accessing this application.</em> </p>
  
  <p>As such, I registered my application in the <a href="https://code.google.com/apis/console/b/0/" rel="noreferrer">Google API Console</a> as a <strong>Service Application</strong>, which gave me a <strong>Client ID</strong> and a <strong>Private Key</strong>. It is my understanding that Service Applications do NOT use <strong>Application Secret</strong> and <strong>Redirect URL</strong> as there is no end-user in this server-to-server authentication flow. Indeed, the Google API Console gave me no Secret and did not prompt me for a Redirect URL.</p>
  
  <p>Unfortunately,  I can not figure out how to authenticate my Service Application within <a href="http://code.google.com/p/google-api-php-client/" rel="noreferrer">Google's PHP Client API</a>. There is extensive documentation on authenticating web applications <strong>with</strong> an end-user.</p>
  
  <p>Google's documentation suggests <a href="https://developers.google.com/accounts/docs/OAuth2ServiceAccount" rel="noreferrer">it is possible to authenticate server-to-server by signing a JWT request with the private key</a>. I just can't figure out how to do within the PHP client API (although I've browsed the source and there's <a href="http://code.google.com/p/google-api-php-client/source/browse/trunk/src/auth/apiP12Signer.php" rel="noreferrer">definitely a script</a> that signs a request with the private key.) </p>
  
  <p>Am I missing something here? How can I perform authentication for a Service Application with my private key and the Google PHP client API?</p>
  
  <p><em>Edited for clarity</em></p>