Description Usage Arguments Details Value Use custom Client ID and Client secret Revoke access application References See Also Examples
authorize()
function uses oauth2.0_token
to obtain the OAuth tokens. Expired tokens will be refreshed automamaticly. If you have no client.id
and client.secret
the package provides predefined values.
1 2 3 4 |
username |
character. Google username email address hint. If not set you will need choose an account for the authorization. |
client.id |
character. OAuth client ID. If you set the environment variable RGA_CLIENT_ID it is used. |
client.secret |
character. OAuth client secret. If you set the environment variable RGA_CLIENT_SECRET it is used. |
cache |
logical or character. |
new.auth |
logical. Set |
After calling this function first time, a web browser will be opened. First, log in with a Google Account, confirm the authorization to access the Google Analytics data. Note that the package requests access for read-only data.
When the authorize()
function is used the GAToken
variable is created in the separate TokenEnv
environment which is not visible for user. So, there is no need to pass the token argument to any function which requires authorization every time. Also there is a possibility to store token in separate variable and to pass it to the functions. It can be useful when you are working with several accounts at the same time.
username
, client.id
, client.secret
and cache
params can be specified by an appropriate options (with “rga” prefix).
A Token2.0
object containing all the data required for OAuth access.
For some reasons you may need to use a custom client ID and client secret. In order to obtain these, you will have to register an application with the Google Analytics API. To find your project's client ID and client secret, do the following:
Go to the Google Developers Console.
Select a project (create if needed).
Select APIs & auth in the sidebar on the left.
In the list of APIs select Analytics API. Then click Enable API.
Select Credentials in the sidebar on the left.
To set up a service account select Create New Client ID. Select Installed Application and Others options and then select Create Client ID.
You can return to the Google Developers Console at any time to view the client ID and client secret on the Client ID for native application section on Credentials page.
There 3 ways to use custom Client ID and Client secret:
Pass the client.id
and client.secret
arguments directly in the authorize()
function call
Set the RGA_CLIENT_ID and RGA_CLIENT_SECRET environment variables
Set the rga.client.id
and rga.client.secret
options
To revoke access the RGA package do the following:
Go to the Apps connected to your account page
Find RGA package entry. Then click on it
Click on the Revoke access button in the sidebar on the right
Other OAuth: oauth_app
oauth2.0_token
Token-class
To revoke all tokens: revoke_all
Setup environment variables: Startup
1 2 3 4 5 6 7 8 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.