Comments (19)
Victory! Using option 1:
Only running drop_auth(rdstoken = "droptoken.rds")
and no dtoken
arg in the drop_
functions. I also moved one drop_
function out of the global chunk (I'm running flexdashboard). It came after the authentication steps, but maybe it was causing a problem.
Works on .io
and connect (as it should).
Very much appreciated, @ClaytonJY!
from rdrop2.
Great, we're getting somewhere!
To be extra clear for future readers, for a shiny app you should include your token as an RDS, and then either
- authenticate with that token like
drop_auth(rdstoken = "tokenfile.rds")
inglobal.R
or at the top ofserver.R
, then call otherdrop_*()
functions normally (without using thedtoken
arg) - do not call
drop_auth()
, read the token into R from the RDS file, then pass that token object into everydrop_*()
function through thedtoken
arg
I think the first option is much, much better (and is what I do), but the second should still be viable.
from rdrop2.
I don't know if this is what you're looking for, but try reading this:
https://daattali.com/shiny/persistent-data-storage/
from rdrop2.
I'm also currently seeing problems with saving the auth token (I wrote the app that @thebiro pointed to)
from rdrop2.
Are folks still having issues? I came across @daattali's excellent post on remote storage for Shiny apps, got everything running locally, then ran into problems in Connect (on a trial now, may move to shinyapps.io).
When publishing from RStudio I included the droptoken.rds
file and called the following in the global:
token <- readRDS("droptoken.rds")
drop_acc(dtoken = token)
Have I missed a step?
In the logs, I as an admin can see Connect wants me to authenticate in the browser.
Waiting for authentication in browser...
from rdrop2.
@ericpgreen hmm...I would expect that to work. I'm not sure what weird stuff shinyapp.io or Rstudio Connect could be doing; this has been working for a couple years in shiny apps on ShinyServer (free) installs I control.
If the logs are private and you aren't worried about leaking some details, could you try printing token
before the drop_acc
call to make sure it has what you expect?
from rdrop2.
Thanks, @ClaytonJY. Here's what I get when I print token
locally. Omitting the key here (maybe that's fine to print here, but wasn't sure).
<Token>
<oauth_endpoint>
authorize: https://www.dropbox.com/oauth2/authorize
access: https://api.dropbox.com/oauth2/token
<oauth_app> dropbox
key: xxxxxxxxxxxx
secret: <hidden>
<credentials> access_token, token_type, uid, account_id
---
from rdrop2.
Well, that looks like a real token! Unfortunately I haven't the slightest clue what's going on here.
I've never had any issues using RDS tokens on ShinyServer instances I install/control, and it's hard to imagine what would be different about Connect.
from rdrop2.
I tried on shinyapps.io as well. I just get the "please wait" animation. In the logs I can see:
2018-09-20T18:54:03.639549+00:00 shinyapps[458677]: Waiting for authentication in browser...
2018-09-20T18:54:03.640039+00:00 shinyapps[458677]: Press Esc/Ctrl + C to abort
2018-09-20T18:54:03.625398+00:00 shinyapps[458677]: Adding .httr-oauth to .gitignore
2018-09-20T18:54:03.642615+00:00 shinyapps[458677]: https://www.dropbox.com/oauth2/authorize?client_id=XXXXXXXXXXXX&redirect_uri=http%3A%2F%2Flocalhost%3A1410%2F&response_type=code&state=XXXXXXXXX
2018-09-20T18:54:03.642116+00:00 shinyapps[458677]: Please point your browser to the following url: )
Does this give any hints?
from rdrop2.
Unfortunately it doesn't; I'm not sure how you're hitting the auth codepath when using drop_acc
; if the token is bad, you should get a negative response from Dropbox, but not be sent through the auth flow.
Is it possible there's another call to a drop_*
function, after drop_acc
, where you don't pass in the token? That would trigger rdrop2:::get_dropbox_token
, which would trigger the auth flow you're seeing. This might not replicate locally because of .httr-oauth
hanging around.
What happens if you explicitly call drop_auth
, like this?
drop_auth(rdstoken = "droptoken.rds") # don't read it first
drop_acc()
That's the recommended (but not well documented) solution for using rdrop2
remotely; set the token once, then don't worry about the dtoken
arg everywhere else.
from rdrop2.
Yes! I had drop_upload(file.path(tempdir(), "master.csv"), path = outputDir)
I misunderstood:
# Then pass the token to each drop_ function
drop_acc(dtoken = token)
To mean: "by running drop_acc(dtoken = token)
, you will automatically pass the token to each drop_ function". It worked locally despite my ignorance for the reason you stated.
Right now I am able to load the app remotely, but I need to investigate a bit further to know if it is related to authentication. Thanks for your help troubleshooting! I'll post back.
from rdrop2.
I fixed the new problem (in troubleshooting I moved a reference to an input$
to the global
chunk) and confirmed everything is working locally again.
-
I tried running
token <- readRDS("droptoken.rds")
ANDdrop_acc(dtoken = token)
AND addingdtoken = token
to alldrop_
functions: still have the remote error of needing to authenticate via the browser. -
Running your approach of
drop_auth(rdstoken = "droptoken.rds")
ANDdrop_acc()
AND keepingdtoken = token
in all functions produced the same result. -
Repeating 2 but dropping
dtoken = token
from the functions produced the same result as well.
Is there a way to store .httr-oauth
remotely? @daattali seems to refer to this here, but I don't know if that is possible on .io
:
The authentication approach I chose was to authenticate manually once and to copy the resulting .httr-oauth file that gets created into the Shiny app’s folder.
@rghertner mentions a different approach here:
Instead of stating
drop_acc(dtoken = token)
, explicitly put in thedtoken=your_token
as the last parameter in all of your functions.
I know this is a dumb question, but I'm not clear on where to find the value of your_token
. Is that what I did in 2 and 3 above? Or is there a different token? (I looked at creating an "app" on Dropbox, and it seems that approach gives a token that is a string rather than the file we're saving to .rds
).
Frustrating! I thought I did all the hard work locally. I'm sure I'm just goofing this up.
from rdrop2.
Sorry @ericpgreen, posted my comment above before seeing your second one.
I suggest not reading in the token yourself, passing the path to drop_auth
(this must happen before any other calls, so put it in global.R
, which it sounds like you might be doing already), and calling all the other functions without dtoken
.
It sounds like you did that in your trial (3) above. It seems like the token is being transferred, because if the file doesn't exist then drop_auth
should throw an error like "token file not found". Could you be doing it in the wrong place, so that a different drop function is being called before auth? That's my only guess at the moment, unfortunately.
from rdrop2.
Awesome! I was really running out of ideas on what could be going wrong, so I'm very glad that worked.
from rdrop2.
Sorry to necro but this helped a lot thanks!
from rdrop2.
Victory! Using option 1:
Only running
drop_auth(rdstoken = "droptoken.rds")
and nodtoken
arg in thedrop_
functions. I also moved onedrop_
function out of the global chunk (I'm running flexdashboard). It came after the authentication steps, but maybe it was causing a problem.Works on
.io
and connect (as it should).Very much appreciated, @ClaytonJY!
hi i dont know if after three year you ppl might get this or not but i am facing same problem as that of
@ericpgreen was facing in 2018. but after you conversation i am still doubt how to handle this issue cany any body elaborate with any chunk code. pardon i dnt have any CS backgroud plus very new on shiny and rdrop
from rdrop2.
@ericpgreen i have tried alot by putting in .server or out of server but not finding how to get out of this same problem
the app is totaly active in local computer but not working for shinyapp.io
from rdrop2.
@zeshan304 I'm not sure this will help, but I searched my files for drop_
and grabbed lines that seem relevant. This is not a full working example (and it's shiny in a flexdashboard, not pure shiny).
---
title: "Title"
resource_files:
- droptoken.rds
- custom.css
runtime: shiny
output:
flexdashboard::flex_dashboard:
css: custom.css
orientation: columns
theme: bootstrap
vertical_layout: fill
---
```{r global, include=FALSE, message=FALSE}
# setup
# -----------------------------------------------------------------------------
library(flexdashboard)
library(shiny)
library(rdrop2)
library(tidyverse)
# authenticate with dropbox for remote storage
# -----------------------------------------------------------------------------
# https://github.com/karthik/rdrop2
# https://github.com/karthik/rdrop2/issues/61#issuecomment-423341288
# run once:
# drop_auth()
# token <- drop_auth()
# saveRDS(token, file = "token.rds") # updload to server with app
outputDir <- "dash" # output directory on Dropox (toplevel)
drop_auth(rdstoken = "droptoken.rds") # give token
```
```{r load, include=FALSE, message=FALSE}
# load files
main <- reactiveValues(df = drop_read_csv("file.csv", stringsAsFactors = FALSE))
```
```{r something}
# submit data
# -----------------------------------------------------------------------------
observeEvent(input$submit, {
# do some stuff
# save to dropbox
write.csv(main$df, file.path(tempdir(), "main.csv"), row.names = FALSE,
quote = TRUE)
drop_upload(file.path(tempdir(), "main.csv"), path = outputDir)
# do some stuff
})
```
from rdrop2.
Thanks a lot its working now
from rdrop2.
Related Issues (20)
- Authentication on virtual machine HOT 5
- BUG: drop_upload() does not return 'response'
- WISH: Completely silent calls
- Specify paths with shared_folder_id HOT 1
- dropbox_save with rdrop2? HOT 2
- Is there any way to use shinyWidgets/shinyhttr along with drop_download() to reflect the progress for downloads? HOT 1
- Documentation for drop_download shows deprecated function in examples
- Auth without a .rds file : is it possible? HOT 1
- Dropbox API Version 2 Updates HOT 2
- drop_delete with dtoken
- drop_share returning "Conflict (HTTP 409)" for some files not yet shared
- drop_upload() not works with ".wav" file
- drop_read : wrapper function for readxl, readRDS, load and readcsv
- drop_auth() generating short lived tokens HOT 13
- Request for autoretry (errors with http 429)
- Token auto-refresh hangs on windows machine HOT 2
- drop_copy / drop_move moving entire file path, not just the selected file
- expired_access_token HOT 1
- Archival on Cran HOT 1
- A version of this package for your version of R might be available elsewhere HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rdrop2.