8-bit-sheep / googleAnalyticsR

Use the Google Analytics API from R
https://8-bit-sheep.com/googleAnalyticsR/
Other
259 stars 76 forks source link

Authentication on RStudio Server #60

Closed toncek87 closed 7 years ago

toncek87 commented 7 years ago

Hi, Currently i use RSstudio Server and my session info is:

`R version 3.3.1 (2016-06-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux 8 (jessie)

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] googleAnalyticsR_0.3.0.9000

loaded via a namespace (and not attached): [1] Rcpp_0.12.9 magrittr_1.5 googleCloudStorageR_0.2.0 devtools_1.12.0 xtable_1.8-2
[6] R6_2.2.0 bigQueryR_0.2.0 httr_1.2.1 dplyr_0.5.0 tools_3.3.1
[11] DBI_0.5 googleAuthR_0.4.0 withr_1.0.2 htmltools_0.3.5 openssl_0.9.4
[16] digest_0.6.12 assertthat_0.1 tibble_1.1 tidyjson_0.2.1 crayon_1.3.2
[21] shiny_1.0.0 curl_1.2 testthat_1.0.2 memoise_1.0.0 mime_0.5
[26] jsonlite_1.2 httpuv_1.3.3 `

I've tried many ways how to connect to GA, but they don't work. Every attempt failed on the URL localhost:1410/?state=........., but RStudio Desktop works correctly.

localhost

Could you give me any advice how to connect RStudio Server to GA with your library?

MarkEdmondson1234 commented 7 years ago

There is an article about this by RStudio, with some options: https://support.rstudio.com/hc/en-us/articles/217952868-Generating-OAuth-tokens-from-a-server

I generally do one of the below:

  1. Generate the httr file offline then upload it
  2. Use the oob option options(httr_oob_default=TRUE), run ga_auth() and then paste in the authentation token in the console prompt
  3. If you are using Google Compute Engine servers, you can use the new googleAuthR feature of authentication reusing the instance's own service account - you need to add the project service email as a user to the Google Analytics account then use the googleAuthR::gar_gce_auth() function to auto auth.
  4. Or make your own service account email, add that as a user to the Google Analytics account and authenticate via googleAuthR::gar_service_auth()