Code Monkey home page Code Monkey logo

Comments (10)

brendan-r avatar brendan-r commented on July 22, 2024

The following env vars (Sys.getenv()) are likely to be useful (tested on Ubuntu):

  • SSH_CONNECTION
    • (only present if there is one)
  • RSTUDIO
    • (present for both server and desktop)
  • RSTUDIO_HTTP_REFERER
    • (present for rstudio server only)

from boxr.

dgarciam avatar dgarciam commented on July 22, 2024

I was actually looking forward on using box-r on rstudio server.
Since Linux doesnt have a box.com client, this was a excellent solution to this, specially since all the data i want to grab is for a shiny app.
Alas! Will have to wait until you figure this out.
Thanks for the package!

from boxr.

brendan-r avatar brendan-r commented on July 22, 2024

In the meantime, you could try setting up your account on a local machine, and then copying over the generated token file (~/.boxr-oauth) to the same place on the server. Once you've done this, running box_auth() from rstudio-server should detect it and authorise you. I haven't tested this myself, but I've seen it discussed as a work-around for other OAuth2.0/httr packages. Let me know how you get on!

from boxr.

dgarciam avatar dgarciam commented on July 22, 2024

Thanks for the tip. I registered on a windows laptop i had around and got the .box-auth.
But it didnt work all the way to validate me.

First of all, it didnt work just copying the .box-oauth. Besides de .boxr-oauth i needed to copy ~/.Renviron as well (was a file with only two lines that contained my box id and box secret).
After that, here are my results:

library(boxr)
Welcome to boxr 0.2.9!
Bug reports: https://github.com/brendan-R/boxr/issues

box_auth()
Reading client id from .Renviron
Reading client secret from .Renviron
Auto-refreshing stale OAuth token.
Error in refresh_oauth2.0(self$endpoint, self$app, self$credentials) :
client error: (400) Bad Request

Can you point me out to the page where you saw this workaround? perhaps i could read a bit from them to see if i needed to do something else.

Thanks!

from boxr.

dgarciam avatar dgarciam commented on July 22, 2024

Well, what do you know.
I tried again and this time it did work.

  1. Refresh on PC
  2. Right away copy token
  3. box_auth()

library(boxr)
Welcome to boxr 0.2.9!
Bug reports: https://github.com/brendan-R/boxr/issues

box_auth()
Reading client id from .Renviron
Reading client secret from .Renviron
boxr: Authenticated at box.com as XXX XXXXX ([email protected])

wonder if i will able to refresh from rstudio now.

Thanks for the pointers! w/o your guidance i would be stuck! Keep the good work and i hope you can sort this hurdle in the near future!

from boxr.

brendan-r avatar brendan-r commented on July 22, 2024

Very glad it worked! 😄

Based on my (wobbly) understanding of OAuth2.0, if auth'ing via two machines does give you problems, setting up separate 'Apps' at box.com (and using separate tokens) is likely to stop this happening. This is more of an issue with API design than the R package I'm afraid.

from boxr.

terrytangyuan avatar terrytangyuan commented on July 22, 2024

Hi Brendan, do you have any progress on this?

I am trying to use it without needing to open the browser and click "yes" to authorize.

from boxr.

brendan-r avatar brendan-r commented on July 22, 2024

I'm afraid having to do the browser part somewhere is the essence of OAuth2.0; there's no way around it with the box.com API.

The token-copying method described above, while annoyingly manual, seems to be the recommended behaviour for similar packages, such as rdrop2. It seems that the googlesheets team made some progress towards making the token-copying part unnecessary, but it doesn't look like it's quite a solved problem yet (though I may be mistaken). I have a suspicion that you'd need to get into the internals of rstudio-server itself to make it work properly.

I'm afraid I'll be unable to spend significant time on this in the near term, but if it's a pressing need for you and you'd like to have a crack at it, I'd be happy to consider a pull request.

from boxr.

terrytangyuan avatar terrytangyuan commented on July 22, 2024

Got it. Thanks. Great job on this package. :-)

from boxr.

brendan-r avatar brendan-r commented on July 22, 2024

Copy and paste method described here (h/t @nwstephens):
https://support.rstudio.com/hc/en-us/articles/217952868

from boxr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.