Open OmarGonD opened 9 years ago
You need to create two different tokens which will have the authorization for the email you authenticate via the Google login page. Its also a lot easier to use the method way described in the readme, but for your examples:
##authenticate with first email
ga_token1 <- authorize(client.id, client.secret, cache = TRUE, verbose = getOption("rga.verbose", FALSE))
##authenticate with second email
ga_token2 <- authorize(client.id, client.secret, cache = TRUE, verbose = getOption("rga.verbose", FALSE))
Then to get accounts:
get_accounts(start.index = NULL, max.results = NULL, ga_token1, verbose = getOption("rga.verbose", FALSE))
get_accounts(start.index = NULL, max.results = NULL, ga_token2, verbose = getOption("rga.verbose", FALSE))
But I would do it this way:
## authenticate under first email
rga.open(instance = "ga1")
## authenticate under second email
rga.open(instance = "ga2")
Then to call data such as profiles:
profiles1 <- ga1$getProfiles()
profiles2 <- ga2$getProfiles()
Hi Mark, thanks for your answer. I think we are talking about different packages. There is this rga package (on github), and there is the other RGA package (from other authors) in CRAN.
i did not know this, so i posted that code here. However, it should be posted in other place.
I was confused, and now i'm trying this with the rga package from "skardhammar". But i still have problems with accesing 2 different google analytics accounts.
This is my code, so someone may help me:
install.packages("devtools")
library(devtools)
install_github("rga", "skardhamar")
library(rga)
rga.open(instance = "ga1",
client.id = "xxxxxxxxxxxxxxxxxxxxx",
client.secret = "yyyyyyyyyyyy")
rga.open(instance = "ga2",
client.id = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz",
client.secret = "wwwwwwwwwwwwww")
ga1$getProfiles()
ga2$getProfiles()
This still gives me the same profiles... what i'm doing wrong?
0 down vote favorite I work with 2 emails for accesing Google Analtics. Each one has access to diffent accounts within Google Analytics. I use email A at my house, and email B at work.
Now, im using RGA (from CRAN) within R, and at my house i need to access the Google Analytics accounts from the Email B (work email, that has access to specific Google Analytics accounts).
The problem is that when using this code:
'ga_token <- authorize(client.id, client.secret, cache = TRUE, verbose = getOption("rga.verbose", FALSE))' Then I use this to get accounts:
'get_accounts(start.index = NULL, max.results = NULL, ga_token, verbose = getOption("rga.verbose", FALSE))'
The problem: is that i want to get the accounts for email B, but no matter what i just get the accounts related with email A.
I've delated all my Google Analytics API projects (from A and B), and recreated the API for Email B. But no matter what, i just get the accounts for email A.
**My Google Api project was created with B (the email with the access to the desire account). But i just see accounts related to A.
What can i do? Thanks