score:0

using mine will require that you are authorized as a user in order to request that data. an api key will only give you access to public data not private data

<script src="https://apis.google.com/js/api.js"></script>
<script>
  /**
   * sample javascript code for youtube.playlists.list
   * see instructions for running apis explorer code samples locally:
   * https://developers.google.com/explorer-help/guides/code_samples#javascript
   */

  function authenticate() {
    return gapi.auth2.getauthinstance()
        .signin({scope: "https://www.googleapis.com/auth/youtube.readonly"})
        .then(function() { console.log("sign-in successful"); },
              function(err) { console.error("error signing in", err); });
  }
  function loadclient() {
    gapi.client.setapikey("your_api_key");
    return gapi.client.load("https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest")
        .then(function() { console.log("gapi client loaded for api"); },
              function(err) { console.error("error loading gapi client for api", err); });
  }
  // make sure the client is loaded and sign-in is complete before calling this method.
  function execute() {
    return gapi.client.youtube.playlists.list({})
        .then(function(response) {
                // handle the results here (response.result has the parsed body).
                console.log("response", response);
              },
              function(err) { console.error("execute error", err); });
  }
  gapi.load("client:auth2", function() {
    gapi.auth2.init({client_id: "your_client_id"});
  });
</script>
<button onclick="authenticate().then(loadclient)">authorize and load</button>
<button onclick="execute()">execute</button>

</body>
</html>

score:0

to use mine,set authorization in header. check this!

https://accounts.google.com/o/oauth2/auth?
  client_id=123456789-sdnjknsdkjf4skfnsdjnsfdksdkjl.apps.googleusercontent.com&
  redirect_uri=http%3a%2f%2flocalhost%2foauth2callback&
  scope=https://www.googleapis.com/auth/youtube&
  response_type=token
 const res = await fetch('https://content-youtube.googleapis.com/youtube/v3/channels
mine=true&part=statistics&key=asdasdasd', 
{ headers: { authorization: `bearer ${token}` } },);

Related Query

More Query from same tag