gtm_auth: Authenticate with Google Analytics OAuth2. Ported AS IS from...

Description Usage Arguments Details Value Auto-authentication

View source: R/auth.R

Description

A wrapper for gar_auth and gar_auth_service

Usage

1
gtm_auth(new_user = FALSE, no_auto = FALSE)

Arguments

new_user

If TRUE, reauthenticate via Google login screen

no_auto

Skip auto authentication

Details

Run this function first time to authenticate with Google in your browser.

After initial authentication, a .httr-oauth will be saved to your working directory, where your authentication details are kept. Keep this file safe.

If you want to reauthenticate, delete this file from your directory or run ga_auth(new_user = TRUE)

Value

Invisibly, the token that has been saved to the session

Auto-authentication

You can choose to auto-authenticate by moving your .httr-oauth or by creating a Google OAuth service account JSON file.

Specify an environment variable in R via a .Renviron file or using Sys.setenv which point to the file location of your chosen authentication file.

Once you have set the environment variable GA_AUTH_FILE to a valid file location, the function will look there for authentication details upon loading the library meaning you will not need to call ga_auth() yourself as you would normally.

An example .Renviron file is below:

GA_AUTH_FILE = "/Users/bob/auth/googleAnalyticsR.httr-oauth"

GA_AUTH_FILE can be either a token generated by gar_auth or service account JSON ending with file extension .json

If you use the service account JSON, you will need to add the service account email to your Google Analytics users to see data e.g. xxxx@yyyyyy.iam.gserviceaccount.com


IronistM/googleTagManageR documentation built on Nov. 6, 2019, 12:16 p.m.