const { google } = require('googleapis');
const credentials = require('json-file-that-you-downloaded-on-google-console.json');
const jwt = new google.auth.JWT({
scopes: [
'https://www.googleapis.com/auth/analytics',
'https://www.googleapis.com/auth/analytics.manage.users',
'https://www.googleapis.com/auth/analytics.edit',
],
});
jwt.fromJSON(credentials);
const analytics = await google.analytics({ version: 'v3' });
const list = await analytics.management.accounts.list({
auth: jwt,
});
const { google } = require('googleapis');
const credentials = require('json-file-that-you-downloaded-on-google-console.json');
const jwt = new google.auth.JWT({
email: credentials.client_email,
key: credentials.private_key,
scopes: [
'https://www.googleapis.com/auth/analytics',
'https://www.googleapis.com/auth/analytics.manage.users',
'https://www.googleapis.com/auth/analytics.edit',
],
});
jwt.fromJSON(credentials);
const analytics = await google.analytics({ version: 'v3' });
const list = await analytics.management.accounts.list({
auth: jwt,
});
const { google } = require('googleapis');
const oauth2Client = new google.auth.OAuth2({
clientId: 'client-id',
clientSecret: 'client-secret',
});
oauth2Client.setCredentials({
access_token: 'access_token'
refresh_token: 'refresh_token',
});
const analytics = await google.analytics({ version: 'v3' });
const list = await analytics.management.accounts.list({
auth: oauth2Client,
});