Auth {RGoogleAnalyticsPremium}R Documentation

Authorize the RGoogleAnalytics package to the user's Google Analytics Account using OAuth2.0

Description

This function expects a Client ID and Client Secret. In order to obtain these, you will have to register an application with the Google Analytics API. This can be done as follows

- Go to https://console.developers.google.com

- Create a New Project and enable the Google Analytics API, Contacts API and Drive API

- On the Credentials screen, create a new Client ID for Application Type "Installed Application".

- Copy the Client ID and Client Secret to your R Script as shown in the Examples section below

Usage

Auth(client.id, client.secret)

Arguments

client.id

Equivalent to a user name

client.secret

Equivalent to a password

Details

When evaluated for the first time this function asks for User Consent for the Google Analytics Account and creates a OAuth Token Object. The token object can be saved locally to a file on the user's system. In subsequent runs, User Consent is not required unless you are querying a Google Analytics profile associated with a different email account. This function uses oauth2.0_token under the hood to create the OAuth Tokens. The Access Token has a 60 minute lifetime after which it expires and a new token has to be obtained. This can be done using the ValidateToken method

Value

google.token A Token object containing all the data required for OAuth access. See Token2.0 for additional information on the Token object

Examples

## Not run: 
# Generate the oauth_token object
oauth_token <- Auth(client.id = "150487456763-XXXXXXXXXXXXXXX.apps.googleusercontent.com",
client.secret = "TUXXXXXXXXXXXX_TknUI")

# Save the token object for future sessions
save(oauth_token, file="oauth_token")

# Load the token object
load("oauth_token")

## End(Not run)

[Package RGoogleAnalyticsPremium version 0.1.1 Index]