Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gar_set_client() ? #1

Open
MarkEdmondson1234 opened this issue Jan 21, 2018 · 3 comments
Open

Use gar_set_client() ? #1

MarkEdmondson1234 opened this issue Jan 21, 2018 · 3 comments

Comments

@MarkEdmondson1234
Copy link
Contributor

Just a quick note to bring to attention the gar_set_client() function, that lets users download client JSON and I've found easier to work with than setting options(googleAuthR.client_id)etc. - that still works obv but I have designs to include this package in gcloudR which will auto authenticate via that method.

@RhysJackson
Copy link
Owner

Thanks. Something like this?

k8s_auth <- function(json = NULL) {
if(is.null(json)) {
googleAuthR::gar_auth()
} else {
googleAuthR::gar_set_client(json)
}
}

@MarkEdmondson1234
Copy link
Contributor Author

No thats a different thing, the gar_set_client() only sets a user's client_id and secret for them, assuming they download the client JSON file and put it in an environment argument GAR_CLIENT_JSON.

Thats opposed to the authentication service JSON (I know) which authenticates a (service) email. I suggest thats done via auto-authentication, but I can submit a pull request for that.

Its the latest iteration that works easiest for me, so a workflow is something like:

library(googleAuthR)
library(googleKubernetesR)

# sets what GCP the auth will go through
gar_set_client()

# does the actual auth
gar_auth()

@RhysJackson
Copy link
Owner

Ok, I think I understand you, though a pull request is very welcome. I'm still just about getting to grips with git so you might have to be patient with me.

There's now three ways to authenticate:

  1. Pass no args to k8s_auth() and rely on the default clientID and clientSecret OAuth credentials
  2. Pass a json arg containing the path to your own clientID and clientSecret creds.
  3. Pass service_account_json arg containing the path to service account credentials.

This is implemented on the 'Authenticataction' branch.

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 {
# Else use gar_auth_service()
googleAuthR::gar_auth_service(service_account_json)
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants