karthik / rdrop2

Dropbox Interface from R
Other
251 stars 57 forks source link

Shinyapps.io error: Warning: Error in : oauth_listener() needs an interactive environment. #48

Open tokumotion opened 8 years ago

tokumotion commented 8 years ago

Hi, when trying to pull data from my dropbox account for a shiny app I get this error. (shinyapps.io logs)

2016-03-19T23:18:38.148996+00:00 shinyapps[86118]: htmltools version: 0.3
2016-03-19T23:18:38.406392+00:00 shinyapps[86118]: Using jsonlite for JSON processing
2016-03-19T23:18:38.410372+00:00 shinyapps[86118]: 
2016-03-19T23:18:38.410375+00:00 shinyapps[86118]: Starting R with process ID: '12'
2016-03-19T23:18:38.430300+00:00 shinyapps[86118]: 
2016-03-19T23:18:38.430304+00:00 shinyapps[86118]: Listening on http://0.0.0.0:44020
2016-03-19T23:18:49.485827+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.485831+00:00 shinyapps[86118]: Attaching package: ‘dplyr’
2016-03-19T23:18:49.485832+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.486483+00:00 shinyapps[86118]: The following objects are masked from ‘package:stats’:
2016-03-19T23:18:49.486485+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.486487+00:00 shinyapps[86118]:     filter, lag
2016-03-19T23:18:49.492350+00:00 shinyapps[86118]: The following objects are masked from ‘package:base’:
2016-03-19T23:18:49.492353+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.492354+00:00 shinyapps[86118]:     intersect, setdiff, setequal, union
2016-03-19T23:18:49.492356+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.573106+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.573111+00:00 shinyapps[86118]: Attaching package: ‘magrittr’
2016-03-19T23:18:49.573112+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.573392+00:00 shinyapps[86118]: The following object is masked from ‘package:tidyr’:
2016-03-19T23:18:49.486488+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.573394+00:00 shinyapps[86118]:     extract
2016-03-19T23:18:49.642772+00:00 shinyapps[86118]: Warning: Error in : oauth_listener() needs an interactive environment.
2016-03-19T23:18:49.649738+00:00 shinyapps[86118]:     62: oauth_listener
2016-03-19T23:18:49.649739+00:00 shinyapps[86118]:     61: init_oauth2.0
2016-03-19T23:18:49.649741+00:00 shinyapps[86118]:     60: self$init_credentials
2016-03-19T23:18:49.649742+00:00 shinyapps[86118]:     59: public_bind_env$initialize
2016-03-19T23:18:49.649743+00:00 shinyapps[86118]:     58: Token2.0$new
2016-03-19T23:18:49.649744+00:00 shinyapps[86118]:     57: httr::oauth2.0_token
2016-03-19T23:18:49.649736+00:00 shinyapps[86118]: Stack trace (innermost first):
2016-03-19T23:18:49.573395+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.573393+00:00 shinyapps[86118]: 
2016-03-19T23:18:49.649749+00:00 shinyapps[86118]:     52: source
2016-03-19T23:18:49.649751+00:00 shinyapps[86118]:     12: fn
2016-03-19T23:18:49.649745+00:00 shinyapps[86118]:     56: drop_auth
2016-03-19T23:18:49.649753+00:00 shinyapps[86118]:     10: tryCatchOne
2016-03-19T23:18:49.649746+00:00 shinyapps[86118]:     55: eval [helper.R#11]
2016-03-19T23:18:49.649755+00:00 shinyapps[86118]:      8: tryCatch
2016-03-19T23:18:49.649756+00:00 shinyapps[86118]:      7: connect$retry
2016-03-19T23:18:49.649750+00:00 shinyapps[86118]:     13: runApp
2016-03-19T23:18:49.649747+00:00 shinyapps[86118]:     54: eval
2016-03-19T23:18:49.649748+00:00 shinyapps[86118]:     53: withVisible
2016-03-19T23:18:49.649762+00:00 shinyapps[86118]:      1: local
2016-03-19T23:18:49.649790+00:00 shinyapps[86118]: Error : oauth_listener() needs an interactive environment.
2016-03-19T23:18:49.649752+00:00 shinyapps[86118]:     11: doTryCatch
2016-03-19T23:18:49.649760+00:00 shinyapps[86118]:      3: eval
2016-03-19T23:18:49.649754+00:00 shinyapps[86118]:      9: tryCatchList
2016-03-19T23:18:49.649757+00:00 shinyapps[86118]:      6: eval
2016-03-19T23:18:49.649758+00:00 shinyapps[86118]:      5: eval
2016-03-19T23:18:49.649759+00:00 shinyapps[86118]:      4: eval
2016-03-19T23:18:49.649761+00:00 shinyapps[86118]:      2: eval.parent

This are the lines of code (on an already authenticated rdrop2 token) I try to run:

token <- readRDS('droptoken.rds')

list_files <- data.frame(name = gsub(".*\\/(.*)\\..*", "\\1", 
                                     drop_dir(drop_search('RData')[7,]$path)$path),
  path = drop_dir(drop_search('RData')[7,]$path)$path, 
  stringsAsFactors = FALSE)

As you can see, the token is already stored in the same folder with the .R files I am trying to run.

I am using the Publish to Server function in the RStudio IDE.

rghertner commented 8 years ago

I ran into the same issue, but found a resolution in trying a different authentication method. Instead of stating drop_acc(dtoken = token), explicitly put in the dtoken=your_token as the last parameter in all of your functions. That fixed it for me.

jtufto commented 7 years ago

The solution of @rghertner does the trick.

cirofdo commented 7 years ago

I uploaded an app into shinyapps.io. The uploaded directory contained my .R code and the token that was made running this code token<-drop_auth().

Like @rghertner said, my drop_ functions contains the dtoken=your_token and it is working fine on different computers logged on different dropbox accounts.

But I don't know what this token does, since anyone can access my app and make changes in the specified dropbox directory.

Is there anyway that I can allow access to it only when logged in that account? Or grant access to few accounts?