title: Google API: Authenticate request with OAuth but without user consent window then request Google data for particular username or user ID
body: <p>While reading this <a href="https://developers.google.com/youtube/v3/guides/authentication#server-side-apps" rel="nofollow">Implementing OAuth 2.0 Authentication (server side)</a> I noticed the process is probably meant for a scenario where one is creating an app that let's users sign in with their Google credentials and subsequently show their Google+ posts, Youtube videos, etc.</p>
  
  <p>What I need is the ability to fetch Google data based on google user's username or user ID. I do have client_id, client_secret, etc. from Google - and I'm willing to send them along my requests.</p>
  
  <p>Step 1 seems OK. Make a request similar to this:</p>
  
  <pre><code>https://accounts.google.com/o/oauth2/auth?
  client_id=1084945748469-eg34imk572gdhu83gj5p0an9fut6urp5.apps.googleusercontent.com&amp;
  redirect_uri=http%3A%2F%2Flocalhost%2Foauth2callback&amp;
  scope=https://www.googleapis.com/auth/youtube&amp;
  response_type=code&amp;
  access_type=offline
  </code></pre>
  
  <p>What would be great after this step is the possibility to just take the code so I can authenticate my request (via Google_Client()->authenticate($_GET['code']); or similar) and then exchange it for the auth_token.</p>
  
  <p>I achieved something similar with Facebook API for PHP for fetching Facebook profile/page public posts - so unlike the sign in with FB process - no user consent is needed nor asked for.</p>