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

Client ID and Secret defaults to package supplied credentials when running deployed shiny apps #74

Closed
emadretina opened this issue Jul 4, 2017 · 11 comments

Comments

@emadretina
Copy link

Not sure if anyone else has seen this problem but when I tried deploying a shiny app it seems like it automatically defaults to the options provided by library rather than using mine. Has anyone else seen this issue?

@MarkEdmondson1234
Copy link
Owner

Hi @emadretina - yes unfortunetly this has come up before here #57 and #59

The fix at the moment is to either use the JS based auth, or to rebuild the package (e.g. clone github, rebuild) locally with your own details, as some kind of caching is taking place on Shinyapps. I'll have another look at this to see if a better fix is available.

@emadretina
Copy link
Author

Thank you, built it locally. Great work by the way, this is an amazingly useful package.

@MarkEdmondson1234
Copy link
Owner

@emadretina may I just check with you, if you were using the CRAN or the GitHub version as it is today? The most recent version has no options specified.

@emadretina
Copy link
Author

It was GitHub version. Also, I would suggest not putting the app id and secret in the code. I modified it to pull those from Env variables for local build.

@MarkEdmondson1234
Copy link
Owner

True, those client id/secret are throw away details but how you did it is the recommended way.

I'm inquiring with Shinyapps on this thread to see if I can do anything.

The very latest googleAuthRGitHub version has the client id/secret stripped away to force users to provide their own now, was that the version you used when deploying to Shinyapps or did it default back to the ones supplied? e.g. these ones:

# googleAuthR.webapp.client_id = "201908948134-cjjs89cffh3k429vi7943ftpk3jg36ed.apps.googleusercontent.com",
# googleAuthR.webapp.client_secret = "mE7rHl0-iNtzyI1MQia-mg1o",

@MarkEdmondson1234
Copy link
Owner

MarkEdmondson1234 commented Jul 5, 2017

Figured thats actually the best way to handle it, let you set your environment arguments which you can do by uploading an .Renviron file with your Shinyapp - the environment arguments are as below:

* Default demo project scopes now NULL, set your own Google Project via `options()` or by setting up environment arguments:
   - `googleAuthR.client_id = Sys.getenv("GAR_CLIENTID")`
   - `googleAuthR.client_secret = Sys.getenv("GAR_CLIENT_SECRET")`
   - `googleAuthR.webapp.client_id = Sys.getenv("GAR_WEB_CLIENTID")`
   - `googleAuthR.webapp.client_secret = Sys.getenv("GAR_WEB_CLIENT_SECRET")`
   - `googleAuthR.scopes.selected = Sys.getenv("GAR_SCOPES")`

@lcolladotor
Copy link

Hm.... I'm not sure that's the syntax for .Renviron. Could you post an example? Is it something like:

GAR_CLIENTID="my id"

or more like:

googleAuthR.client_id = "My id"

I'm guessing it's the first option. In any case, it's good to know that this issue has been solved ^^.

@MarkEdmondson1234
Copy link
Owner

MarkEdmondson1234 commented Jul 5, 2017

Its the former, but you have to restart your R session to see it. Here are examples I have in my Home directory as seen by RStudio

#.Renviron
GAR_CLIENTID="kjsjfkjsfsf"
GAR_CLIENT_SECRET="sasdsad"

After restarting R they are reachable via:

Sys.getenv("GAR_CLIENTID")
Sys.getenv("GAR_CLIENT_SECRET")

and subsequently should be in the options via

getOption("googleAuthR.client_id")
getOption("googleAuthR.client_secret")

@lcolladotor
Copy link

Excellent, thanks!

@MarkEdmondson1234
Copy link
Owner

Hmm, you can't pass vectors if you want to do multiple scopes, so I'll set that up that you need a comma delimiter:

#.Renviron
GAR_CLIENTID="kjsjfkjsfsf"
GAR_CLIENT_SECRET="sasdsad"
GAR_SCOPES="scope1,scope2,scope3"

@MarkEdmondson1234
Copy link
Owner

I just need a confirmation this clears up the issue, no rebuilding needed. I'll run a test myself next week-ish

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

3 participants