Learn R Programming

GAR (version 1.1)

tokenRefresh: Retrieves a Google Analytics access token using a refresh token.

Description

This function retrieves a Google Analytics access token using a supplied refresh token. Refresh tokens do not expire and can be traded for an access token repeatedly. The function will pull from the following environmental variables by default: GAR_CLIENT_ID, GAR_CLIENT_SECRET, GAR_REFRESH_TOKEN. Additionally, a temporary variable (GAR_ACCESS_TOKEN) will be stored in a package specific environment (envGAR) containing the newly generated access token for use in the getRequest() function.

Usage

tokenRefresh(client_id, client_secret, token)

Arguments

client_id
Client ID found in API Console. String format.
client_secret
Client Secret found in API Console. String format.
token
Refresh token as originally generated manually. String format.

Value

Access token is a string to be used in conjunction with gaRequest() function.

Details

Function returns a GA access token.

References

https://developers.google.com/analytics/devguides/reporting/core/v3/

See Also

GAR gaRequest getCode getRefresh tokenRefresh

Examples

Run this code

tokenRefresh(
            client_id="ABCDEFG",
            client_secret="HIJKLMNOP",
            token="QRSTUVWX"
            )

Run the code above in your browser using DataLab