0

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 = "ga-analysis@managemrnt-dashboard.iam.gserviceaccount.com",
        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.

Steve
  • 575
  • 4
  • 18
  • some other information on secrets maybe relevant here https://stackoverflow.com/questions/63535190/connect-to-googlesheets-via-shiny-in-r-with-googlesheets4 – Mike Mar 21 '23 at 13:53
  • The blogpost is from 2020, and it could be some changes were made in the packages that are not described there. Have you seen the official docs for the package: https://code.markedmondson.me/googleAnalyticsR/articles/setup.html – novica Mar 21 '23 at 14:10

0 Answers0