Closed abalter closed 3 years ago
We need more info, such as how you are setting the client.id and what you want scopes you want to authenticate for. The error message suggests the client.id is not set correctly.
Yes--it's hard to provide a reproducible example, especially in that it involves opening a browser.
When I use the bigrquery
pacakge, I run bq_auth(email="me@someplace.com")
. If I have not already configured my authentication, a google sign in page opens in my browser. I log in, and then I'm all set.
When I use googleAuthR
and run gar_auth()
a browser window opens and displays the authorization error shown.
Hopefully that explains the issue. Please let me know what other information I can provide to help find the problem.
What are you trying to do - use gar_auth()
instead of bq_auth()
? Perhaps looking at how bigQueryR does it will help:
https://github.com/cloudyr/bigQueryR/blob/master/R/auth.R
bqr_auth <- function(json_file = NULL,
token = NULL,
email = Sys.getenv("GARGLE_EMAIL")){
set_scopes()
if(is.null(json_file)){
gar_auth(token = token,
email = email,
package = "bigQueryR")
} else {
gar_auth_service(json_file = json_file)
}
}
set_scopes <- function(){
required_scopes <- c("https://www.googleapis.com/auth/bigquery",
"https://www.googleapis.com/auth/cloud-platform")
op <- getOption("googleAuthR.scopes.selected")
if(is.null(op)){
options(googleAuthR.scopes.selected = "https://www.googleapis.com/auth/bigquery")
} else if(!any(op %in% required_scopes)){
myMessage("Adding https://www.googleapis.com/auth/bigquery to scopes", level = 3)
options(googleAuthR.scopes.selected = c(op, "https://www.googleapis.com/auth/bigquery"))
}
}
They both use gargle underneath.
I'm trying to access GCS (buckets). BigQuery works great.
I'm really trying to use googleCloudStorageR
. The only signature for gcs_auth
is to use a json file. I thought I'd try the generic authentication in googleAuthR
.
Ok sounds like you'll be best to use googleCloudStorage's gcs_auth()
- v0.6.0 just hit CRAN and it lets you use email as well, or you can use gcs_setup()
to create and set the JSON key file for you. I prefer the JSON file since it is more stable and supports long uploads.
What goes wrong
Authentication throwing 400 Authentication Error
Note that this process works correctly with
bigrquery
.Steps to reproduce the problem
Please note that if a reproduceable example that I can run is not available, then the likelihood of getting any bug fixed is low.
Expected output
Taken to google web authentication page.
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
Session Info
Please run
sessionInfo()
so we can check what versions of packages you have installed