Google Analytics Authentication in R Using googleAnalyticsR

147 Views Asked by At

I am building a flexdashboard to highlight data from Google Analytics. Using the googleAnalyticsR package. I followed the directions on this Posit post: https://posit.co/blog/google-analytics-part1/ to the letter. Here is the code I'm executing:


## First, authenticate with our client OAUTH credentials from step 5 of the blog post.
googleAuthR::gar_set_client(json = ".secrets/XXX.json")

## Now, provide the service account email and private key
ga_auth(email = "[email protected]",
        json_file = ".secrets/YYY.json")

## At this point, we should be properly authenticated and ready to go. We can test this
## by getting a list of all the accounts that this test project has access to. Typically,
## this will be only one if you've created your own service key. If it isn't your only
## account, select the appropriate viewId from your list of accounts.

my_accounts <- ga_account_list()

my_accounts is an empty data frame, and I can't figure why. I imagine it must be something really deep in the Google authentication ecosystem, but I've double-checked everything many times.

If I just use a regular call to ga_auth(), I am able to authenticate (through a web popup), and when I authenticate that way, my_accounts has data in it.

I know this is somewhat vague, but it's all I have to go on.

0

There are 0 best solutions below