title: Making request to youtube data api with already existing credentials
body: <p>I'm trying to make authorized requests to youtube data API to get information on a users activity and subscriptions. In my application I do the authorization flow using <a href="http://passportjs.org/" rel="nofollow noreferrer">passportjs</a> with the <a href="https://github.com/yanatan16/passport-youtube-v3" rel="nofollow noreferrer">passport-youtube-v3 strategy</a>. For this reason I already have authorisation tokens required for accessing a users data. For me it is not clear though how I am supposed to use the youtube API if I already have user credentials. Here's my flow and where I struggle: </p>
  
  <ol>
  <li><p>Acquire user credentials (token) using passportjs.</p></li>
  <li><p>Making a "manual" request to youtube data API using <a href="https://www.npmjs.com/package/axios" rel="nofollow noreferrer">axios</a> or any other request library for that matter:</p>
  
  <pre><code>const baseUri = "https://www.googleapis.com/youtube/v3/subscriptions";
  const opts = {
    params: {
      part: "snippet",
      mine: true,
      fields: "items(snippet(title%2C+channelId%2Cthumbnails%2Fdefault%2Furl))",
      key: youtubeAuth.clientID,
      access_token: user.youtube.token
    }
  }
  
  return axios.get(baseUri, opts)
    .then(response =&gt; {
      console.log(response);
    })
    .catch(err =&gt; {
      console.log(err);
    });
  </code></pre></li>
  </ol>
  
  <p>My key parameter looks something like this: </p>
  
  <pre><code>857220510254-q8pkdd9ugp2be167s5ged7ave4pqa5rn.apps.googleusercontent.com
  </code></pre>
  
  <p>And tokens look something like this </p>
  
  <pre><code>ya29.GlttZIaiVLxzaZDu-5-KTd5jRHhqh684Q4PFoUF3_72D9Ig0uz9CyrLwnotKMOUcnZ93kTVoYH5Bc6WCfUS1tNY5DbEMDN7nCeiUMU9vmkQWLTUAaKVS3A7XhB65
  </code></pre>
  
  <p>This doesn't seem to be the correct way of doing it since I keep getting a 401 error:</p>
  
  <pre><code>{
      "error": {
          "errors": [
              {
                  "domain": "global",
                  "reason": "authError",
                  "message": "Invalid Credentials",
                  "locationType": "header",
                  "location": "Authorization"
              }
          ],
          "code": 401,
          "message": "Invalid Credentials"
      }
  }
  </code></pre>
  
  <p>Is it even possible to do this this way or do I have to use the google SDKs as shown in the <a href="https://developers.google.com/youtube/v3/quickstart/nodejs" rel="nofollow noreferrer">nodejs quickstart example</a>?</p>