title: How to pass an access_token to YouTube API v3?
body: <p>I'm trying to make an authorized call to YouTube Data API v3, as it's described here:
  <a href="https://developers.google.com/youtube/v3/docs/activities/list" rel="nofollow noreferrer">https://developers.google.com/youtube/v3/docs/activities/list</a></p>
  
  <p>I got everything working fine, until I get to the part, where the access token is needed.</p>
  
  <p>I've added GoogleID Sign In, that gives me an access token with the following scopes:</p>
  
  <pre><code>"https://www.googleapis.com/auth/youtube"
  "https://www.googleapis.com/auth/youtube.force-ssl"
  "https://www.googleapis.com/auth/youtube.readonly"
  </code></pre>
  
  <p>Those are three scopes, that are mentioned and used at google's reference.</p>
  
  <pre class="lang-swift prettyprint-override"><code>let url = NSURL(string: theURLString)
  
  let sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration()
  let sessionQueue = NSOperationQueue.mainQueue()
  
  let session = NSURLSession(configuration: sessionConfig, delegate: self, delegateQueue: sessionQueue)
  
  let request = NSMutableURLRequest(URL: url!)
  request.HTTPMethod = "GET"
  request.addValue("application/json", forHTTPHeaderField: "Content-Type")
  request.addValue("application/json", forHTTPHeaderField: "Accept")
  
  if Settings.sharedInstance.isLoggedIn {
      request.setValue("Bearer \(Settings.sharedInstance.userToken!)", forHTTPHeaderField: "Authorization")
  }
  
  let task = session.downloadTaskWithRequest(request)
  
  task.resume()
  </code></pre>
  
  <p>And after the call I got the following answer:</p>
  
  <pre><code>{
  error =     {
      code = 401;
      errors =         (
                      {
              domain = global;
              location = Authorization;
              locationType = header;
              message = "Invalid Credentials";
              reason = authError;
          }
      );
      message = "Invalid Credentials";
  };
  }
  </code></pre>
  
  <p>And I've already tried to make calls with the access_token in the URL string:</p>
  
  <pre><code>theURLString = "https://www.googleapis.com/youtube/v3/activities?part=snippet,contentDetails&amp;home=true&amp;maxResults=10&amp;key=\(googleAPIKey)&amp;access_token=\(Settings.sharedInstance.userToken!)"
  </code></pre>
  
  <p>And get the following:</p>
  
  <pre><code>{
  error =     {
      code = 401;
      errors =         (
                      {
              domain = "youtube.parameter";
              location = home;
              locationType = parameter;
              message = "The request uses the &lt;code&gt;home&lt;/code&gt; parameter but is not properly authorized.";
              reason = authorizationRequired;
          }
      );
      message = "The request uses the &lt;code&gt;home&lt;/code&gt; parameter but is not properly authorized.";
  };
  }
  </code></pre>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>Found Google OAuth playground:
  <a href="https://developers.google.com/oauthplayground/" rel="nofollow noreferrer">https://developers.google.com/oauthplayground/</a></p>
  
  <p>Taking access token from that playground and adding it hard coded to the code doesn't change the response in both cases.</p>