bigrquery - Get new token with a different email address

29 Views Asked by At

I am trying to change the email that I use to read data from bigrquery.

When I use

bq_auth()
bq_user()

I get my work email

 bq_user()
[1] "[email protected]"

If I deauth, and reauthenticate:

> bq_deauth()
> bq_user()
NULL
> bq_auth(email="[email protected]")
> bq_user()
[1] "[email protected]"

I have tried getting a token from gargle directly...

> token = gargle::token_fetch(email="[email protected]",scopes = scopes)
> bq_auth(token = token)
> bq_user()
[1] "[email protected]"

What is odd is that if I remove the scopes...

> token = gargle::token_fetch(email="[email protected]")
> bq_auth(token = token)
> bq_user()
[1] "[email protected]"

but as you can guess... the scopes are wrong.

> bq_tb <- bq_project_query("com-biotech-myproject", query="SELECT * FROM `com-biotech.CoolDataset.Fake2`")
Error in `signal_reason()`:
! Request had insufficient authentication scopes. [insufficientPermissions] 
Run `rlang::last_trace()` to see where the error occurred.

Is this a bug, or am I doing something wrong?

> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.4

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

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

other attached packages:
[1] bigrquery_1.4.2 devtools_2.4.5  usethis_2.2.0  

loaded via a namespace (and not attached):
 [1] rappdirs_0.3.3    utf8_1.2.3        generics_0.1.3    stringi_1.7.12    digest_0.6.31     magrittr_2.0.3   
 [7] grid_4.3.0        pkgload_1.3.2     fastmap_1.1.1     jsonlite_1.8.5    processx_3.8.1    pkgbuild_1.4.1   
[13] sessioninfo_1.2.2 DBI_1.1.3         urlchecker_1.0.1  ps_1.7.5          promises_1.2.0.1  httr_1.4.6       
[19] purrr_1.0.1       fansi_1.0.4       scales_1.2.1      cli_3.6.1         shiny_1.7.4       rlang_1.1.1      
[25] crayon_1.5.2      dbplyr_2.3.2      bit64_4.0.5       ellipsis_0.3.2    munsell_0.5.0     remotes_2.4.2    
[31] cachem_1.0.8      tools_4.3.0       gargle_1.5.0      memoise_2.0.1     dplyr_1.1.2       colorspace_2.1-0 
[37] ggplot2_3.4.2     httpuv_1.6.11     curl_5.0.1        assertthat_0.2.1  vctrs_0.6.2       R6_2.5.1         
[43] mime_0.12         lifecycle_1.0.3   stringr_1.5.0     bit_4.0.5         fs_1.6.2          htmlwidgets_1.6.2
[49] miniUI_0.1.1.1    pkgconfig_2.0.3   callr_3.7.3       pillar_1.9.0      later_1.3.1       gtable_0.3.3     
[55] glue_1.6.2        profvis_0.3.8     Rcpp_1.0.10       tidyselect_1.2.0  tibble_3.2.1      rstudioapi_0.14  
[61] xtable_1.8-4      htmltools_0.5.5   compiler_4.3.0    prettyunits_1.1.1 askpass_1.1       openssl_2.0.6 

UPDATE:
I have a temporary workaround, maybe it helps...

token <- gargle::credentials_user_oauth2(scopes = scopes)
The gargle package is requesting access to your Google account.
Enter '1' to start a new auth process or select a pre-authorized account.
1: Send me to the browser for a new auth process.
2: [email protected]
Selection: 1
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
> bq_auth(token = token)
> bq_user()
[1] "[email protected]"

so I'm thinking this use case is problematic for gargle::token_fetch. I don't know why it is always using my work email first. Maybe I set this up sometime in the past and forgot about it?

0

There are 0 best solutions below