Closed arthurlin-kmd closed 3 years ago
Hi @MarkEdmondson1234, I have managed to authenticate myself after reinstalling the latest Base R and RStudio.
Thank you so much for your time!
Ok! Glad you are up and running.
Hi @MarkEdmondson1234 , I am running into this same issue as well, after switching to a new PC. gar_auth() works fine on my old machine, but returns Error: Could not authenticate via any gargle cred function
on my new one.
I'm guessing I'm missing a file or setting somewhere on the new machine, but do you have any other troubleshooting steps I should try before going the full re-install route?
After restarting R and setting options(googleAuthR.verbose=2)
and running gar_auth()
, I receive the same output as the user above.
> options(googleAuthR.verbose=2)
> library(googleAnalyticsR)
i 2021-10-18 09:00:42 > Set API cache
i 2021-10-18 09:00:42 > No environment argument found, looked in GA_AUTH_FILE
i 2021-10-18 09:00:42 > No consent file found
You can opt in to tracking of your use of googleAnalyticsR - see ?measurementProtocol::mp_trackme for details.
> ga_auth()
i 2021-10-18 09:01:01 > Default Google Project for googleAnalyticsR is set.
This is shared with all googleAnalyticsR users.
If making a lot of API calls, please visit:
https://gtm2.markedmondson.me/gar-setup
for instructions on setting your own Google Project
i 2021-10-18 09:01:01 > Setting client.id from options(googleAuthR.client_id)
Error: Could not authenticate via any gargle cred function
>
I think you probably need to reset your authentication file that its using in the automatic process. What environment arguments do you have set? Try issuing ga_auth(email="your@email.com")
to re-generate the OAuth2 token.
Thanks @MarkEdmondson1234 . Issuing the ga_auth(email="your@email.com")
with my email returned the same error.
Can you clarify what exactly is meant by "environment arguments" or how I would verify? I cleared my global environment as well but that didn't seem to affect anything.
Environment arguments refer to checking if you have an .Renviron file in your R home directory or project folder that are setting up R variables, but I guess if you don't know about it you have not.
The authentication menu is not appearing for some reasons, could you restart R, try again and give your session info by using sessionInfo()
? This is mine below - if you have anything out of date please update it.
R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.6
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] googleAnalyticsR_1.0.1
loaded via a namespace (and not attached):
[1] pillar_1.6.1 compiler_4.1.0 googleAuthR_1.4.0.9000
[4] tools_4.1.0 digest_0.6.27 jsonlite_1.7.2
[7] evaluate_0.14 memoise_2.0.0 lifecycle_1.0.0
[10] gargle_1.2.0 tibble_3.1.2 pkgconfig_2.0.3
[13] rlang_0.4.11 cli_3.0.1 DBI_1.1.1
[16] rstudioapi_0.13 curl_4.3.1 xfun_0.23
[19] fastmap_1.1.0 withr_2.4.2 dplyr_1.0.6
[22] httr_1.4.2 knitr_1.33 askpass_1.1
[25] generics_0.1.0 fs_1.5.0 vctrs_0.3.8
[28] rappdirs_0.3.3 tidyselect_1.1.1 glue_1.4.2
[31] R6_2.5.0 fansi_0.5.0 measurementProtocol_0.1.0.9000
[34] rmarkdown_2.8 purrr_0.3.4 tidyr_1.1.3
[37] magrittr_2.0.1 whisker_0.4 ellipsis_0.3.2
[40] htmltools_0.5.1.1 usethis_2.0.1 assertthat_0.2.1
[43] utf8_1.2.1 openssl_1.4.4 cachem_1.0.5
[46] crayon_1.4.1
@MarkEdmondson1234 Here's my session info - all my packages are up to date and I don't see any major differences in the google or gargle ones.
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] googleAuthR_1.4.0 googleAnalyticsR_1.0.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 later_1.3.0 pillar_1.6.3 compiler_4.1.1 tools_4.1.1
[6] digest_0.6.28 jsonlite_1.7.2 memoise_2.0.0 lifecycle_1.0.1 tibble_3.1.5
[11] gargle_1.2.0 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11 DBI_1.1.1
[16] cli_3.0.1 rstudioapi_0.13 curl_4.3.2 fastmap_1.1.0 withr_2.4.2
[21] dplyr_1.0.7 httr_1.4.2 rappdirs_0.3.3 generics_0.1.0 vctrs_0.3.8
[26] fs_1.5.0 grid_4.1.1 tidyselect_1.1.1 glue_1.4.2 R6_2.5.1
[31] fansi_0.5.0 measurementProtocol_0.1.0 whisker_0.4 ggplot2_3.3.5 purrr_0.3.4
[36] tidyr_1.1.4 magrittr_2.0.1 usethis_2.1.0 scales_1.1.1 ellipsis_0.3.2
[41] assertthat_0.2.1 colorspace_2.0-2 utf8_1.2.2 munsell_0.5.0 cachem_1.0.6
[46] crayon_1.4.1
I did find a gargle-oauth folder/file on my old machine, which I don't see anywhere on my new one. Is that the authentication file you're referring to that may need reset?
It's odd sorry I don't see a reason why it doesn't work for you. I suggest going through the steps to add your own clientId since that will refresh your token. That involves setting up a GCP project and using ga_auth_setup() - if that also errors please open a new issue.
Summary
This is an issue raised on gargle repo, link to the issue - https://github.com/r-lib/gargle/issues/188
What goes wrong
I have attempted to replicate
2. Make your first API call
on https://code.markedmondson.me/googleAnalyticsR/articles/setup.html, but have been getting error messageError: Could not authenticate via any gargle cred function
Steps to reproduce the problem
Expected output
I was expecting to see a prompt in the browser for GA API authentication but that never came up.
Actual output
Before you run your code, please run:
options(googleAuthR.verbose=2)
and copy-paste the console output here.Check it doesn't include any sensitive info like auth tokens or accountIds - you can usually just edit those out manually and replace with say
XXX