Skip to content

Commit

Permalink
web json client messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEdmondson1234 committed Sep 6, 2019
1 parent e95925a commit 3c721c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Add default scope of "https://www.googleapis.com/auth/cloud-platform" to `gar_gce_auth()`
* Improvements to stop `gar_auto_auth()` block library installation if auth files not correct.
* Allow to be used by R 3.3 via custom `isFALSE` function (#158 - thanks @matthijsvanderloos)
* Web JSON client id messaging

# googleAuthR v1.0.0

Expand Down
24 changes: 12 additions & 12 deletions R/set_client.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,23 @@ gar_set_client <- function(json = Sys.getenv("GAR_CLIENT_JSON"),
## web apps
if(web_json != ""){
assert_that(is.readable(web_json))
web_json <- fromJSON(web_json)
web_json_content <- fromJSON(web_json)

if(is.null(web_json$web)){
if(is.null(web_json_content$web)){
stop("$web not found in JSON - have you downloaded the correct JSON file for web apps?
(Service account client > Web Application, not Service Account Keys or Other)",
call. = FALSE)
}

options(googleAuthR.webapp.client_id = web_json$web$client_id,
googleAuthR.webapp.client_secret = web_json$web$client_secret)
options(googleAuthR.webapp.client_id = web_json_content$web$client_id,
googleAuthR.webapp.client_secret = web_json_content$web$client_secret)

# fix for shinyapps #57 etc
Sys.setenv("GAR_WEB_CLIENTID" = web_json$web$client_id)
Sys.setenv("GAR_WEB_CLIENT_SECRET" = web_json$web$client_secret)
Sys.setenv("GAR_WEB_CLIENTID" = web_json_content$web$client_id)
Sys.setenv("GAR_WEB_CLIENT_SECRET" = web_json_content$web$client_secret)
Sys.setenv("GAR_SCOPES" = paste(scopes, collapse = ","))

project_id <- web_json$web$project_id
project_id <- web_json_content$web$project_id

}

Expand All @@ -111,19 +111,19 @@ gar_set_client <- function(json = Sys.getenv("GAR_CLIENT_JSON"),
# set it manually instead
myMessage(paste("Setting web client.id from ", web_json), level = 3)
app <- oauth_app(
paste0("web-",web_json$web$project_id),
key = web_json$web$client_id,
secret = web_json$web$client_secret
paste0("web-",web_json_content$web$project_id),
key = web_json_content$web$client_id,
secret = web_json_content$web$client_secret
)

gar_auth_configure(app = app)
}


if(web_json != "" && json != ""){
if(web_json$web$project_id != the_json$installed$project_id){
if(web_json_content$web$project_id != the_json$installed$project_id){
warning("Web and offline projects don't match:",
"Web:", web_json$web$project_id,
"Web:", web_json_content$web$project_id,
"Installed:", the_json$installed$project_id,
call. = FALSE)
}
Expand Down

0 comments on commit 3c721c0

Please sign in to comment.