Issues Authenticating/accessing YouTube API in Meteor

I am trying to grab data from the YouTube Analytics API. My Meteor project involves users logging into the site using their Google accounts through OAuth 2.0 (I’m using the accounts-google package for this) and when signing in I need them to be able to see some data from the YouTube Analytics API for their YouTube channel.

I have added the proper scopes to my accounts-google login system, and I can see accessToken, idToken, expiresAt, refreshToken, etc. under services.

Using the “Try It” API Explorer on the YouTube Analytics API Documentation page, I can get the type of response I’m looking for through this request:


It’s gotten a little messy but this is where I currently am at:

//// TestingClient.js ////

var params = {
  'start-date': "2015-10-01",
  'end-date': "2015-10-31",
  'metrics': "views",
  'dimensions': "day",
  'sort': "-day"

var currentAccessToken = Meteor.user();

var opts = {
  channelId: "MINE",
  currentAccessToken: currentAccessToken
};'getYoutubeReports', opts.channelId, opts.currentAccessToken, params, function(error, result) {

//// In Server.js ////

Meteor.publish("userData", function () {
    return Meteor.users.find({_id: this.userId},
        {fields: {'services': 1}});

Meteor.publish(null, function() {
  if (this.userId != null) {
    return Meteor.users.find({
      _id: this.userId
    }, {
      fields: {
        'createdAt': 1,
        'services': 1,
  } else {
    return this.ready();

  getYoutubeReports: function(channelId, access_token, params) {
    params.ids = "channel=="+ channelId;
    params.key = access_token;
    return HTTP.get("", 

With the code above all I receive is a ‘Invalid Credentials’ error in my console log.

I feel like there is probably a better way to go about what I’m trying to achieve but I’m really quite lost, any information/example code is extremely appreciated.

Edit: I forgot to mention I have also added the HTTP package for this.

I am using this package to not care about token renewals etc

Thank for sharing! I seen it before but went with the node.js client instead to handle refreshes, I honestly can’t remember why I went with that instead though… I’ll definitely take a look into that package some more!