github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/docs/content/box.md (about) 1 --- 2 title: "Box" 3 description: "Rclone docs for Box" 4 versionIntroduced: "v1.38" 5 --- 6 7 # {{< icon "fa fa-archive" >}} Box 8 9 Paths are specified as `remote:path` 10 11 Paths may be as deep as required, e.g. `remote:directory/subdirectory`. 12 13 The initial setup for Box involves getting a token from Box which you 14 can do either in your browser, or with a config.json downloaded from Box 15 to use JWT authentication. `rclone config` walks you through it. 16 17 ## Configuration 18 19 Here is an example of how to make a remote called `remote`. First run: 20 21 rclone config 22 23 This will guide you through an interactive setup process: 24 25 ``` 26 No remotes found, make a new one? 27 n) New remote 28 s) Set configuration password 29 q) Quit config 30 n/s/q> n 31 name> remote 32 Type of storage to configure. 33 Choose a number from below, or type in your own value 34 [snip] 35 XX / Box 36 \ "box" 37 [snip] 38 Storage> box 39 Box App Client Id - leave blank normally. 40 client_id> 41 Box App Client Secret - leave blank normally. 42 client_secret> 43 Box App config.json location 44 Leave blank normally. 45 Enter a string value. Press Enter for the default (""). 46 box_config_file> 47 Box App Primary Access Token 48 Leave blank normally. 49 Enter a string value. Press Enter for the default (""). 50 access_token> 51 52 Enter a string value. Press Enter for the default ("user"). 53 Choose a number from below, or type in your own value 54 1 / Rclone should act on behalf of a user 55 \ "user" 56 2 / Rclone should act on behalf of a service account 57 \ "enterprise" 58 box_sub_type> 59 Remote config 60 Use web browser to automatically authenticate rclone with remote? 61 * Say Y if the machine running rclone has a web browser you can use 62 * Say N if running rclone on a (remote) machine without web browser access 63 If not sure try Y. If Y failed, try N. 64 y) Yes 65 n) No 66 y/n> y 67 If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth 68 Log in and authorize rclone for access 69 Waiting for code... 70 Got code 71 -------------------- 72 [remote] 73 client_id = 74 client_secret = 75 token = {"access_token":"XXX","token_type":"bearer","refresh_token":"XXX","expiry":"XXX"} 76 -------------------- 77 y) Yes this is OK 78 e) Edit this remote 79 d) Delete this remote 80 y/e/d> y 81 ``` 82 83 See the [remote setup docs](/remote_setup/) for how to set it up on a 84 machine with no Internet browser available. 85 86 Note that rclone runs a webserver on your local machine to collect the 87 token as returned from Box. This only runs from the moment it opens 88 your browser to the moment you get back the verification code. This 89 is on `http://127.0.0.1:53682/` and this it may require you to unblock 90 it temporarily if you are running a host firewall. 91 92 Once configured you can then use `rclone` like this, 93 94 List directories in top level of your Box 95 96 rclone lsd remote: 97 98 List all the files in your Box 99 100 rclone ls remote: 101 102 To copy a local directory to an Box directory called backup 103 104 rclone copy /home/source remote:backup 105 106 ### Using rclone with an Enterprise account with SSO 107 108 If you have an "Enterprise" account type with Box with single sign on 109 (SSO), you need to create a password to use Box with rclone. This can 110 be done at your Enterprise Box account by going to Settings, "Account" 111 Tab, and then set the password in the "Authentication" field. 112 113 Once you have done this, you can setup your Enterprise Box account 114 using the same procedure detailed above in the, using the password you 115 have just set. 116 117 ### Invalid refresh token 118 119 According to the [box docs](https://developer.box.com/v2.0/docs/oauth-20#section-6-using-the-access-and-refresh-tokens): 120 121 > Each refresh_token is valid for one use in 60 days. 122 123 This means that if you 124 125 * Don't use the box remote for 60 days 126 * Copy the config file with a box refresh token in and use it in two places 127 * Get an error on a token refresh 128 129 then rclone will return an error which includes the text `Invalid 130 refresh token`. 131 132 To fix this you will need to use oauth2 again to update the refresh 133 token. You can use the methods in [the remote setup 134 docs](/remote_setup/), bearing in mind that if you use the copy the 135 config file method, you should not use that remote on the computer you 136 did the authentication on. 137 138 Here is how to do it. 139 140 ``` 141 $ rclone config 142 Current remotes: 143 144 Name Type 145 ==== ==== 146 remote box 147 148 e) Edit existing remote 149 n) New remote 150 d) Delete remote 151 r) Rename remote 152 c) Copy remote 153 s) Set configuration password 154 q) Quit config 155 e/n/d/r/c/s/q> e 156 Choose a number from below, or type in an existing value 157 1 > remote 158 remote> remote 159 -------------------- 160 [remote] 161 type = box 162 token = {"access_token":"XXX","token_type":"bearer","refresh_token":"XXX","expiry":"2017-07-08T23:40:08.059167677+01:00"} 163 -------------------- 164 Edit remote 165 Value "client_id" = "" 166 Edit? (y/n)> 167 y) Yes 168 n) No 169 y/n> n 170 Value "client_secret" = "" 171 Edit? (y/n)> 172 y) Yes 173 n) No 174 y/n> n 175 Remote config 176 Already have a token - refresh? 177 y) Yes 178 n) No 179 y/n> y 180 Use web browser to automatically authenticate rclone with remote? 181 * Say Y if the machine running rclone has a web browser you can use 182 * Say N if running rclone on a (remote) machine without web browser access 183 If not sure try Y. If Y failed, try N. 184 y) Yes 185 n) No 186 y/n> y 187 If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth 188 Log in and authorize rclone for access 189 Waiting for code... 190 Got code 191 -------------------- 192 [remote] 193 type = box 194 token = {"access_token":"YYY","token_type":"bearer","refresh_token":"YYY","expiry":"2017-07-23T12:22:29.259137901+01:00"} 195 -------------------- 196 y) Yes this is OK 197 e) Edit this remote 198 d) Delete this remote 199 y/e/d> y 200 ``` 201 202 ### Modification times and hashes 203 204 Box allows modification times to be set on objects accurate to 1 205 second. These will be used to detect whether objects need syncing or 206 not. 207 208 Box supports SHA1 type hashes, so you can use the `--checksum` 209 flag. 210 211 ### Restricted filename characters 212 213 In addition to the [default restricted characters set](/overview/#restricted-characters) 214 the following characters are also replaced: 215 216 | Character | Value | Replacement | 217 | --------- |:-----:|:-----------:| 218 | \ | 0x5C | \ | 219 220 File names can also not end with the following characters. 221 These only get replaced if they are the last character in the name: 222 223 | Character | Value | Replacement | 224 | --------- |:-----:|:-----------:| 225 | SP | 0x20 | ␠ | 226 227 Invalid UTF-8 bytes will also be [replaced](/overview/#invalid-utf8), 228 as they can't be used in JSON strings. 229 230 ### Transfers 231 232 For files above 50 MiB rclone will use a chunked transfer. Rclone will 233 upload up to `--transfers` chunks at the same time (shared among all 234 the multipart uploads). Chunks are buffered in memory and are 235 normally 8 MiB so increasing `--transfers` will increase memory use. 236 237 ### Deleting files 238 239 Depending on the enterprise settings for your user, the item will 240 either be actually deleted from Box or moved to the trash. 241 242 Emptying the trash is supported via the rclone however cleanup command 243 however this deletes every trashed file and folder individually so it 244 may take a very long time. 245 Emptying the trash via the WebUI does not have this limitation 246 so it is advised to empty the trash via the WebUI. 247 248 ### Root folder ID 249 250 You can set the `root_folder_id` for rclone. This is the directory 251 (identified by its `Folder ID`) that rclone considers to be the root 252 of your Box drive. 253 254 Normally you will leave this blank and rclone will determine the 255 correct root to use itself. 256 257 However you can set this to restrict rclone to a specific folder 258 hierarchy. 259 260 In order to do this you will have to find the `Folder ID` of the 261 directory you wish rclone to display. This will be the last segment 262 of the URL when you open the relevant folder in the Box web 263 interface. 264 265 So if the folder you want rclone to use has a URL which looks like 266 `https://app.box.com/folder/11xxxxxxxxx8` 267 in the browser, then you use `11xxxxxxxxx8` as 268 the `root_folder_id` in the config. 269 270 {{< rem autogenerated options start" - DO NOT EDIT - instead edit fs.RegInfo in backend/box/box.go then run make backenddocs" >}} 271 ### Standard options 272 273 Here are the Standard options specific to box (Box). 274 275 #### --box-client-id 276 277 OAuth Client Id. 278 279 Leave blank normally. 280 281 Properties: 282 283 - Config: client_id 284 - Env Var: RCLONE_BOX_CLIENT_ID 285 - Type: string 286 - Required: false 287 288 #### --box-client-secret 289 290 OAuth Client Secret. 291 292 Leave blank normally. 293 294 Properties: 295 296 - Config: client_secret 297 - Env Var: RCLONE_BOX_CLIENT_SECRET 298 - Type: string 299 - Required: false 300 301 #### --box-box-config-file 302 303 Box App config.json location 304 305 Leave blank normally. 306 307 Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`. 308 309 Properties: 310 311 - Config: box_config_file 312 - Env Var: RCLONE_BOX_BOX_CONFIG_FILE 313 - Type: string 314 - Required: false 315 316 #### --box-access-token 317 318 Box App Primary Access Token 319 320 Leave blank normally. 321 322 Properties: 323 324 - Config: access_token 325 - Env Var: RCLONE_BOX_ACCESS_TOKEN 326 - Type: string 327 - Required: false 328 329 #### --box-box-sub-type 330 331 332 333 Properties: 334 335 - Config: box_sub_type 336 - Env Var: RCLONE_BOX_BOX_SUB_TYPE 337 - Type: string 338 - Default: "user" 339 - Examples: 340 - "user" 341 - Rclone should act on behalf of a user. 342 - "enterprise" 343 - Rclone should act on behalf of a service account. 344 345 ### Advanced options 346 347 Here are the Advanced options specific to box (Box). 348 349 #### --box-token 350 351 OAuth Access Token as a JSON blob. 352 353 Properties: 354 355 - Config: token 356 - Env Var: RCLONE_BOX_TOKEN 357 - Type: string 358 - Required: false 359 360 #### --box-auth-url 361 362 Auth server URL. 363 364 Leave blank to use the provider defaults. 365 366 Properties: 367 368 - Config: auth_url 369 - Env Var: RCLONE_BOX_AUTH_URL 370 - Type: string 371 - Required: false 372 373 #### --box-token-url 374 375 Token server url. 376 377 Leave blank to use the provider defaults. 378 379 Properties: 380 381 - Config: token_url 382 - Env Var: RCLONE_BOX_TOKEN_URL 383 - Type: string 384 - Required: false 385 386 #### --box-root-folder-id 387 388 Fill in for rclone to use a non root folder as its starting point. 389 390 Properties: 391 392 - Config: root_folder_id 393 - Env Var: RCLONE_BOX_ROOT_FOLDER_ID 394 - Type: string 395 - Default: "0" 396 397 #### --box-upload-cutoff 398 399 Cutoff for switching to multipart upload (>= 50 MiB). 400 401 Properties: 402 403 - Config: upload_cutoff 404 - Env Var: RCLONE_BOX_UPLOAD_CUTOFF 405 - Type: SizeSuffix 406 - Default: 50Mi 407 408 #### --box-commit-retries 409 410 Max number of times to try committing a multipart file. 411 412 Properties: 413 414 - Config: commit_retries 415 - Env Var: RCLONE_BOX_COMMIT_RETRIES 416 - Type: int 417 - Default: 100 418 419 #### --box-list-chunk 420 421 Size of listing chunk 1-1000. 422 423 Properties: 424 425 - Config: list_chunk 426 - Env Var: RCLONE_BOX_LIST_CHUNK 427 - Type: int 428 - Default: 1000 429 430 #### --box-owned-by 431 432 Only show items owned by the login (email address) passed in. 433 434 Properties: 435 436 - Config: owned_by 437 - Env Var: RCLONE_BOX_OWNED_BY 438 - Type: string 439 - Required: false 440 441 #### --box-impersonate 442 443 Impersonate this user ID when using a service account. 444 445 Setting this flag allows rclone, when using a JWT service account, to 446 act on behalf of another user by setting the as-user header. 447 448 The user ID is the Box identifier for a user. User IDs can found for 449 any user via the GET /users endpoint, which is only available to 450 admins, or by calling the GET /users/me endpoint with an authenticated 451 user session. 452 453 See: https://developer.box.com/guides/authentication/jwt/as-user/ 454 455 456 Properties: 457 458 - Config: impersonate 459 - Env Var: RCLONE_BOX_IMPERSONATE 460 - Type: string 461 - Required: false 462 463 #### --box-encoding 464 465 The encoding for the backend. 466 467 See the [encoding section in the overview](/overview/#encoding) for more info. 468 469 Properties: 470 471 - Config: encoding 472 - Env Var: RCLONE_BOX_ENCODING 473 - Type: Encoding 474 - Default: Slash,BackSlash,Del,Ctl,RightSpace,InvalidUtf8,Dot 475 476 #### --box-description 477 478 Description of the remote 479 480 Properties: 481 482 - Config: description 483 - Env Var: RCLONE_BOX_DESCRIPTION 484 - Type: string 485 - Required: false 486 487 {{< rem autogenerated options stop >}} 488 489 ## Limitations 490 491 Note that Box is case insensitive so you can't have a file called 492 "Hello.doc" and one called "hello.doc". 493 494 Box file names can't have the `\` character in. rclone maps this to 495 and from an identical looking unicode equivalent `\` (U+FF3C Fullwidth 496 Reverse Solidus). 497 498 Box only supports filenames up to 255 characters in length. 499 500 Box has [API rate limits](https://developer.box.com/guides/api-calls/permissions-and-errors/rate-limits/) that sometimes reduce the speed of rclone. 501 502 `rclone about` is not supported by the Box backend. Backends without 503 this capability cannot determine free space for an rclone mount or 504 use policy `mfs` (most free space) as a member of an rclone union 505 remote. 506 507 See [List of backends that do not support rclone about](https://rclone.org/overview/#optional-features) and [rclone about](https://rclone.org/commands/rclone_about/) 508 509 ## Get your own Box App ID 510 511 Here is how to create your own Box App ID for rclone: 512 513 1. Go to the [Box Developer Console](https://app.box.com/developers/console) 514 and login, then click `My Apps` on the sidebar. Click `Create New App` 515 and select `Custom App`. 516 517 2. In the first screen on the box that pops up, you can pretty much enter 518 whatever you want. The `App Name` can be whatever. For `Purpose` choose 519 automation to avoid having to fill out anything else. Click `Next`. 520 521 3. In the second screen of the creation screen, select 522 `User Authentication (OAuth 2.0)`. Then click `Create App`. 523 524 4. You should now be on the `Configuration` tab of your new app. If not, 525 click on it at the top of the webpage. Copy down `Client ID` 526 and `Client Secret`, you'll need those for rclone. 527 528 5. Under "OAuth 2.0 Redirect URI", add `http://127.0.0.1:53682/` 529 530 6. For `Application Scopes`, select `Read all files and folders stored in Box` 531 and `Write all files and folders stored in box` (assuming you want to do both). 532 Leave others unchecked. Click `Save Changes` at the top right.