box_auth serves two purposes:

  1. Setting up box.com accounts with boxr for the first time

  2. Connecting to previously used box.com accounts

In either case, it should be sufficient to run box_auth() with no parameters. If you've authenticated with boxr before, this should be all that is required. However, the first time you use boxr, the process is slightly more involved (see 'Getting Set-Up' below).

box_auth(client_id = "", client_secret = "", interactive = TRUE,
  cache = "~/.boxr-oauth", write.Renv = TRUE, ...)

Arguments

client_id

Optional. The client id for the account you'd like to use. character.

client_secret

Optional. The client secret for the account you'd like to use. character.

interactive

logical. Should the authorization process happen interactively (requiring user input to the R console, and/or a visit to box.com)?

cache

Passed to cache in httr().

write.Renv

logical. If authentication was successful, should client_id and client_secret be written to .Renvirons in your HOME directory?

...

Passed to oauth2.0_token()

Value

Returns TRUE if connection successful, throws an error otherwise. Invoked for it's side effect; OAuth2.0 connection to the box.com API.

Your client_id and client_secret will be written to ~/.Renviron for future use, and a token object will be wrttien to the path supplied bu cache (~/.boxr-oauth by default).

See oauth2.0_token() for details.

Getting Set-Up

A version of this guide is in the package vignette, with some additional screenshots. To view the vignette, run vignette("boxr"). To use boxr for the first time, you need to enable API access for your box.com account. The process is slightly annoying. You only need to do it once - it takes around 2 minutes.

The next time you use boxr, you should be able to just run box_auth() (without entering anything else) to be authenticated and ready-to-go.

  1. Create an app At Box Developers Center, click on 'My Apps', in the top right hand corner log in and create a new 'app' for your box.com account. This won't create an app of any description; you'll simply be granting yourself programmatic access to your files. You can call it anything you like.

  2. Set OAuth2 Parameters On the next screen, you'll want to check the box for 'Content API Access Only', and enter 'http://localhost as your redirect_uri.

  3. Connect boxr to your account Run box_auth() and pass your client_id and client_secret to the console when prompted. These strings are not' enough for someone to access your account maliciously. However, it's still a good idea to keep them safe, and out of any files or code which might be shared with others.

A browser window should open, for you to formally grant yourself access to your files at box.com.

From this point on, simply running box_auth() at the start of a session should be all that is required.

See also

box_auth_on_attach(), oauth2.0_token() for details of how the tokens are handled