Skip to content

handle server to server auth #54

@zippeurfou

Description

@zippeurfou

Using google JWT.
i.e. in node js googleapis it works like that:

var google = require('googleapis');
var analytics = google.analytics({
    version: 'v3'
});
var jwtClient = new google.auth.JWT(
    config.ga.client_email,
    null,
    config.ga.private_key, ['https://www.googleapis.com/auth/analytics.readonly'],
    null)

Then you can access your data as follow:

analytics.get({
        'ids': 'ga:123456789',
        'start-date': timestamp_start,
        'end-date': timestamp_start,
        'metrics': 'ga:sessions',
        'dimensions': 'ga:socialActivityContentUrl',
        'sort': '-ga:sessions',
        'max-results': 10000,
        auth: jwtClient
    })

Therefore, you only need an email and private key and it does the rest for you (no need to auth via a webpage).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions