Access Youtube API using Meteor package and percolate google-api

I just started my first meteor project, and I'm trying to access the youtube API.

I created the developer credentials using google and I enabled the ui accounts and percolation of the google-api packages. I can successfully log in with accounts-ui, which means that my OAuth settings work.

Then I try to run something like this on the client:

GoogleApi.get('youtube/v3/search',{
    part : 'snippet',
    q : 'cats',
    maxResults : 25
  },
  function(err,data) {
    !err ? console.log(data) : console.log(err);
  });

And I get the following error on the console:

Error: failed [403] {  "error": {   "errors": [    {     "domain": "global",     "reason": "insufficientPermissions",     "message": "Insufficient Permission"    }   ],   "code": 403,   "message": "Insufficient Permission"  } } 

I’m not sure if I call the function incorrectly, since I can’t find examples of using the GoogleApi.get () function (and I am a beginning meteorite), or my developer account is not configured correctly, or what.

Any help or pointers you can go through is greatly appreciated. Thank!

: FullStack , :

var url = "https://www.googleapis.com/youtube/v3/search";
        var params = {
            key: {Google API Key}
            part: "snippet",
            q: searchTerm,
            maxResults: 25
        };
        Meteor.http.get(url, {params: params}, function (err, result) {
            console.log(result.statusCode, result.data);
            var retdata = result.data;
            Session.set("youtubeSearchItems", retdata.items);
        });
+4
2

google-api HTTP . :

  var url = "https://www.googleapis.com/youtube/v3/search";
  var options = {
    'headers' : {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer ' + yourAccessToken,
      'X-JavaScript-User-Agent': "Google APIs Explorer"
    },
    'params' : {
       part : 'snippet',
       q : 'cats',
       maxResults : 25
    }
  };

  var searchResult = HTTP.get(url, options);

, HTTP: meteor add http . Meteor HTTP.

+5

Percolate . , insufficient permissions. , , API-, .

if (Meteor.isClient){
  var scopes = [
    'https://www.googleapis.com/auth/youtube',
  ];
  Accounts.ui.config({
    requestPermissions: {google: scopes}
  });
}

, API YouTube , . . :

https://developers.google.com/youtube/v3/guides/auth/client-side-web-apps

0

All Articles