Reputation: 1
I'm trying to generate an access token via a JWT client using Google's node.js client library as mentioned here.
Here's the code snippet I'm following:
const { google } = require('googleapis')
const key = require('./auth.json')
const scopes = 'https://www.googleapis.com/auth/analytics.readonly'
const jwt = new google.auth.JWT(key.client_email, null, key.private_key, scopes)
const view_id = 'Your View ID'
jwt.authorize((err, response) => {
google.analytics('v3').data.ga.get(
{
auth: jwt,
ids: 'ga:' + view_id,
'start-date': '30daysAgo',
'end-date': 'today',
metrics: 'ga:pageviews'
},
(err, result) => {
console.log(err, result)
}
)
})
But I keep getting this error message:
TypeError: Cannot read property 'auth' of undefined
Anyone know what's causing this?
Upvotes: 0
Views: 130