Skip to content

Commit

Permalink
Auth changes
Browse files Browse the repository at this point in the history
Implement authentication with service accounts
  • Loading branch information
RhysJackson committed Jan 21, 2018
1 parent 8bb9377 commit 5fa5eac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.RData
test.R
.httr-oauth
secret.json
service_account\.json
client_secret\.json
19 changes: 15 additions & 4 deletions R/k8s_auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@
#'
#' Calls googleAuthR to authenticate with the Google Cloud Platform
#' @keywords k8s_auth
#' @param json Path to your json client_secret credentials.
#' @param json OPTIONAL Path to your JSON client_secret credentials.
#' @param service_account_json OPTIONAL Path to your JSON service account credentials
#' @importFrom googleAuthR gar_auth
#' @export
#' @examples
#' k8s_auth()
#' k8s_auth(json = "client_secret.json")
#' k8s_auth(service_account_json = "service_account.json")

k8s_auth <- function(json = NULL) {
if(is.null(json)) {
k8s_auth <- function(json = NULL, service_account_json = NULL) {

if(!is.null(json)) {
# If json client ID credentials are provided, use gar_set_client() to set the credentials
googleAuthR::gar_set_client(json)
}

if(is.null(service_account_json)) {
# If no service token provided, use gar_auth()
googleAuthR::gar_auth()
} else {
googleAuthR::gar_set_client(json)
# Else use gar_auth_service()
googleAuthR::gar_auth_service(service_account_json)
}

}
7 changes: 5 additions & 2 deletions man/k8s_auth.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5fa5eac

Please sign in to comment.