MarkEdmondson1234 / googleAuthR

Google API Client Library for R. Easy authentication and help to build Google API R libraries with OAuth2. Shiny compatible.
https://code.markedmondson.me/googleAuthR
Other
175 stars 51 forks source link

gar_set_client() - 'project_id' not found #190

Open MarkEdmondson1234 opened 4 years ago

MarkEdmondson1234 commented 4 years ago

Rstudio Server:

Verbose output:

ℹ 2020-07-30 15:48:27 > 
options(googleAuthR.scopes.selected=c(' https://www.googleapis.com/auth/webmasters ')) 
options(googleAuthR.client_id='  ') 
options(googleAuthR.client_secret='  ') 
options(googleAuthR.webapp.client_id='XXX.apps.googleusercontent.com ') 
options(googleAuthR.webapp.client_secret='YYYYYY')
Error in gar_set_client(web_json = "client.json", scopes = "https://www.googleapis.com/auth/webmasters") : 
  object 'project_id' not found

Sessioninfo:

R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS:   /usr/lib/libblas/libblas.so.3.7.0
LAPACK: /usr/lib/lapack/liblapack.so.3.7.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] 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   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] rvest_0.3.2              xml2_1.2.0              
 [3] googleAuthR_1.3.0.9000   stringr_1.3.1           
 [5] plotly_4.8.0             ggplot2_3.1.0           
 [7] shinyjqui_0.3.3          shinyBS_0.61            
 [9] shinycustomloader_0.9.0  DT_0.5                  
[11] purrr_0.2.5              shinydashboardPlus_0.6.0
[13] shinycssloaders_0.2.0    lubridate_1.7.4         
[15] dplyr_0.8.0.1            dygraphs_1.1.1.6        
[17] CausalImpact_1.2.3       bsts_0.8.0              
[19] xts_0.11-2               zoo_1.8-4               
[21] BoomSpikeSlab_1.0.0      Boom_0.8                
[23] MASS_7.3-51.1            searchConsoleR_0.3.0    
[25] shinyWidgets_0.4.8       shinyjs_1.0             
[27] shiny_1.3.2              shinydashboard_0.7.1    

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0        lattice_0.20-38   tidyr_0.8.2      
 [4] assertthat_0.2.1  digest_0.6.25     packrat_0.5.0    
 [7] mime_0.9          R6_2.4.1          plyr_1.8.4       
[10] httr_1.4.2        pillar_1.3.1      rlang_0.4.7      
[13] lazyeval_0.2.1    rstudioapi_0.8    data.table_1.11.8
[16] htmlwidgets_1.3   munsell_0.5.0     compiler_3.6.2   
[19] httpuv_1.5.1      pkgconfig_2.0.2   htmltools_0.3.6  
[22] tidyselect_0.2.5  tibble_2.1.1      viridisLite_0.3.0
[25] fansi_0.4.1       crayon_1.3.4      withr_2.2.0      
[28] later_0.8.0       grid_3.6.2        jsonlite_1.7.0   
[31] xtable_1.8-3      gtable_0.2.0      magrittr_1.5     
[34] scales_1.0.0      cli_2.0.2         stringi_1.2.4    
[37] fs_1.4.2          promises_1.0.1    tools_3.6.2      
[40] glue_1.4.1        colorspace_1.3-2  gargle_0.5.0     
[43] memoise_1.1.0    

Maybe lets ignore my PC for now then ;)

Originally posted by @domsle in https://github.com/MarkEdmondson1234/googleAuthR/issues/188#issuecomment-666377308

MarkEdmondson1234 commented 4 years ago

You can't activate both at the same time (client_id and web client) due to some gargle thing, so if you have both you need to add the argument activate="web" e.g.

gar_set_client(activate="web")
daattali commented 3 years ago

It would be useful to add this bit of information to the setup vignette

The current steps are as follows for Shiny:

- Click ‘Create a new Client ID’, and choose “Web Application”.
- Download the web client JSON file
- Add the URL of where your Shiny app will run to the credentials, with no port number. e.g. https://your-account.shinyapps.io/your-shiny-app/
- And/Or also put in localhost or 127.0.0.1 with a port number for local testing. Remember the port number you use as you will need it later to launch the app e.g. http://127.0.0.1:1221
- Set the GAR_CLIENT_WEB_JSON environment argument (via .Renviron or otherwise) to the full path file location of the JSON file (see gar_set_client() for other options)
- Run the app locally specifying the port number you used e.g. shiny::runApp(port=1221)
- Or deploy to your Shiny Server that deploys to web port (80 or 443).

If you just follow these steps, you get the project_id error. Especially since the next vignette https://code.markedmondson.me/googleAuthR/articles/google-authentication-types.html in the Shiny section says to use gar_set_client(scopes = "https://www.googleapis.com/auth/drive"). In the setup guide there's instructions how to get the JSON file for use in shiny, and in the authentication guide there's an example of the actual function call to gar_set_client(), but this alone won't work. It would be useful to mention to new users that because this is a web json, the correct parameters need to be set.