github.com/artpar/rclone@v1.67.3/docs/content/onedrive.md (about)

     1  ---
     2  title: "Microsoft OneDrive"
     3  description: "Rclone docs for Microsoft OneDrive"
     4  versionIntroduced: "v1.24"
     5  ---
     6  
     7  # {{< icon "fab fa-windows" >}} Microsoft OneDrive
     8  
     9  Paths are specified as `remote:path`
    10  
    11  Paths may be as deep as required, e.g. `remote:directory/subdirectory`.
    12  
    13  ## Configuration
    14  
    15  The initial setup for OneDrive involves getting a token from
    16  Microsoft which you need to do in your browser.  `rclone config` walks
    17  you through it.
    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  e) Edit existing remote
    27  n) New remote
    28  d) Delete remote
    29  r) Rename remote
    30  c) Copy remote
    31  s) Set configuration password
    32  q) Quit config
    33  e/n/d/r/c/s/q> n
    34  name> remote
    35  Type of storage to configure.
    36  Enter a string value. Press Enter for the default ("").
    37  Choose a number from below, or type in your own value
    38  [snip]
    39  XX / Microsoft OneDrive
    40     \ "onedrive"
    41  [snip]
    42  Storage> onedrive
    43  Microsoft App Client Id
    44  Leave blank normally.
    45  Enter a string value. Press Enter for the default ("").
    46  client_id>
    47  Microsoft App Client Secret
    48  Leave blank normally.
    49  Enter a string value. Press Enter for the default ("").
    50  client_secret>
    51  Edit advanced config? (y/n)
    52  y) Yes
    53  n) No
    54  y/n> n
    55  Remote config
    56  Use web browser to automatically authenticate rclone with remote?
    57   * Say Y if the machine running rclone has a web browser you can use
    58   * Say N if running rclone on a (remote) machine without web browser access
    59  If not sure try Y. If Y failed, try N.
    60  y) Yes
    61  n) No
    62  y/n> y
    63  If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth
    64  Log in and authorize rclone for access
    65  Waiting for code...
    66  Got code
    67  Choose a number from below, or type in an existing value
    68   1 / OneDrive Personal or Business
    69     \ "onedrive"
    70   2 / Sharepoint site
    71     \ "sharepoint"
    72   3 / Type in driveID
    73     \ "driveid"
    74   4 / Type in SiteID
    75     \ "siteid"
    76   5 / Search a Sharepoint site
    77     \ "search"
    78  Your choice> 1
    79  Found 1 drives, please select the one you want to use:
    80  0: OneDrive (business) id=b!Eqwertyuiopasdfghjklzxcvbnm-7mnbvcxzlkjhgfdsapoiuytrewqk
    81  Chose drive to use:> 0
    82  Found drive 'root' of type 'business', URL: https://org-my.sharepoint.com/personal/you/Documents
    83  Is that okay?
    84  y) Yes
    85  n) No
    86  y/n> y
    87  --------------------
    88  [remote]
    89  type = onedrive
    90  token = {"access_token":"youraccesstoken","token_type":"Bearer","refresh_token":"yourrefreshtoken","expiry":"2018-08-26T22:39:52.486512262+08:00"}
    91  drive_id = b!Eqwertyuiopasdfghjklzxcvbnm-7mnbvcxzlkjhgfdsapoiuytrewqk
    92  drive_type = business
    93  --------------------
    94  y) Yes this is OK
    95  e) Edit this remote
    96  d) Delete this remote
    97  y/e/d> y
    98  ```
    99  
   100  See the [remote setup docs](/remote_setup/) for how to set it up on a
   101  machine with no Internet browser available.
   102  
   103  Note that rclone runs a webserver on your local machine to collect the
   104  token as returned from Microsoft. This only runs from the moment it
   105  opens your browser to the moment you get back the verification
   106  code.  This is on `http://127.0.0.1:53682/` and this it may require
   107  you to unblock it temporarily if you are running a host firewall.
   108  
   109  Once configured you can then use `rclone` like this,
   110  
   111  List directories in top level of your OneDrive
   112  
   113      rclone lsd remote:
   114  
   115  List all the files in your OneDrive
   116  
   117      rclone ls remote:
   118  
   119  To copy a local directory to an OneDrive directory called backup
   120  
   121      rclone copy /home/source remote:backup
   122  
   123  ### Getting your own Client ID and Key
   124  
   125  rclone uses a default Client ID when talking to OneDrive, unless a custom `client_id` is specified in the config.
   126  The default Client ID and Key are shared by all rclone users when performing requests.
   127  
   128  You may choose to create and use your own Client ID, in case the default one does not work well for you. 
   129  For example, you might see throttling.
   130  
   131  #### Creating Client ID for OneDrive Personal
   132  
   133  To create your own Client ID, please follow these steps:
   134  
   135  1. Open https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade and then click `New registration`.
   136  2. Enter a name for your app, choose account type `Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)`, select `Web` in `Redirect URI`, then type (do not copy and paste) `http://localhost:53682/` and click Register. Copy and keep the `Application (client) ID` under the app name for later use.
   137  3. Under `manage` select `Certificates & secrets`, click `New client secret`. Enter a description (can be anything) and set `Expires` to 24 months. Copy and keep that secret _Value_ for later use (you _won't_ be able to see this value afterwards).
   138  4. Under `manage` select `API permissions`, click `Add a permission` and select `Microsoft Graph` then select `delegated permissions`.
   139  5. Search and select the following permissions: `Files.Read`, `Files.ReadWrite`, `Files.Read.All`, `Files.ReadWrite.All`, `offline_access`, `User.Read` and `Sites.Read.All` (if custom access scopes are configured, select the permissions accordingly). Once selected click `Add permissions` at the bottom.
   140  
   141  Now the application is complete. Run `rclone config` to create or edit a OneDrive remote.
   142  Supply the app ID and password as Client ID and Secret, respectively. rclone will walk you through the remaining steps.
   143  
   144  The access_scopes option allows you to configure the permissions requested by rclone.
   145  See [Microsoft Docs](https://docs.microsoft.com/en-us/graph/permissions-reference#files-permissions) for more information about the different scopes.
   146  
   147  The `Sites.Read.All` permission is required if you need to [search SharePoint sites when configuring the remote](https://github.com/artpar/artpar/pull/5883). However, if that permission is not assigned, you need to exclude `Sites.Read.All` from your access scopes or set `disable_site_permission` option to true in the advanced options.
   148  
   149  #### Creating Client ID for OneDrive Business
   150  
   151  The steps for OneDrive Personal may or may not work for OneDrive Business, depending on the security settings of the organization.
   152  A common error is that the publisher of the App is not verified.
   153  
   154  You may try to [verify you account](https://docs.microsoft.com/en-us/azure/active-directory/develop/publisher-verification-overview), or try to limit the App to your organization only, as shown below.
   155  
   156  1. Make sure to create the App with your business account.
   157  2. Follow the steps above to create an App. However, we need a different account type here: `Accounts in this organizational directory only (*** - Single tenant)`. Note that you can also change the account type after creating the App.
   158  3. Find the [tenant ID](https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/active-directory-how-to-find-tenant) of your organization.
   159  4. In the rclone config, set `auth_url` to `https://login.microsoftonline.com/YOUR_TENANT_ID/oauth2/v2.0/authorize`.
   160  5. In the rclone config, set `token_url` to `https://login.microsoftonline.com/YOUR_TENANT_ID/oauth2/v2.0/token`.
   161  
   162  Note: If you have a special region, you may need a different host in step 4 and 5. Here are [some hints](https://github.com/artpar/artpar/blob/bc23bf11db1c78c6ebbf8ea538fbebf7058b4176/backend/onedrive/onedrive.go#L86).
   163  
   164  
   165  ### Modification times and hashes
   166  
   167  OneDrive allows modification times to be set on objects accurate to 1
   168  second.  These will be used to detect whether objects need syncing or
   169  not.
   170  
   171  OneDrive Personal, OneDrive for Business and Sharepoint Server support
   172  [QuickXorHash](https://docs.microsoft.com/en-us/onedrive/developer/code-snippets/quickxorhash).
   173  
   174  Before rclone 1.62 the default hash for Onedrive Personal was `SHA1`.
   175  For rclone 1.62 and above the default for all Onedrive backends is
   176  `QuickXorHash`.
   177  
   178  Starting from July 2023 `SHA1` support is being phased out in Onedrive
   179  Personal in favour of `QuickXorHash`. If necessary the
   180  `--onedrive-hash-type` flag (or `hash_type` config option) can be used
   181  to select `SHA1` during the transition period if this is important
   182  your workflow.
   183  
   184  For all types of OneDrive you can use the `--checksum` flag.
   185  
   186  ### --fast-list
   187  
   188  This remote supports `--fast-list` which allows you to use fewer
   189  transactions in exchange for more memory. See the [rclone
   190  docs](/docs/#fast-list) for more details.
   191  
   192  This must be enabled with the `--onedrive-delta` flag (or `delta =
   193  true` in the config file) as it can cause performance degradation.
   194  
   195  It does this by using the delta listing facilities of OneDrive which
   196  returns all the files in the remote very efficiently. This is much
   197  more efficient than listing directories recursively and is Microsoft's
   198  recommended way of reading all the file information from a drive.
   199  
   200  This can be useful with `rclone mount` and [rclone rc vfs/refresh
   201  recursive=true](/rc/#vfs-refresh)) to very quickly fill the mount with
   202  information about all the files.
   203  
   204  The API used for the recursive listing (`ListR`) only supports listing
   205  from the root of the drive. This will become increasingly inefficient
   206  the further away you get from the root as rclone will have to discard
   207  files outside of the directory you are using.
   208  
   209  Some commands (like `rclone lsf -R`) will use `ListR` by default - you
   210  can turn this off with `--disable ListR` if you need to.
   211  
   212  ### Restricted filename characters
   213  
   214  In addition to the [default restricted characters set](/overview/#restricted-characters)
   215  the following characters are also replaced:
   216  
   217  | Character | Value | Replacement |
   218  | --------- |:-----:|:-----------:|
   219  | "         | 0x22  | "          |
   220  | *         | 0x2A  | *          |
   221  | :         | 0x3A  | :          |
   222  | <         | 0x3C  | <          |
   223  | >         | 0x3E  | >          |
   224  | ?         | 0x3F  | ?          |
   225  | \         | 0x5C  | \          |
   226  | \|        | 0x7C  | |          |
   227  
   228  File names can also not end with the following characters.
   229  These only get replaced if they are the last character in the name:
   230  
   231  | Character | Value | Replacement |
   232  | --------- |:-----:|:-----------:|
   233  | SP        | 0x20  | ␠           |
   234  | .         | 0x2E  | .          |
   235  
   236  File names can also not begin with the following characters.
   237  These only get replaced if they are the first character in the name:
   238  
   239  | Character | Value | Replacement |
   240  | --------- |:-----:|:-----------:|
   241  | SP        | 0x20  | ␠           |
   242  | ~         | 0x7E  | ~          |
   243  
   244  Invalid UTF-8 bytes will also be [replaced](/overview/#invalid-utf8),
   245  as they can't be used in JSON strings.
   246  
   247  ### Deleting files
   248  
   249  Any files you delete with rclone will end up in the trash.  Microsoft
   250  doesn't provide an API to permanently delete files, nor to empty the
   251  trash, so you will have to do that with one of Microsoft's apps or via
   252  the OneDrive website.
   253  
   254  {{< rem autogenerated options start" - DO NOT EDIT - instead edit fs.RegInfo in backend/onedrive/onedrive.go then run make backenddocs" >}}
   255  ### Standard options
   256  
   257  Here are the Standard options specific to onedrive (Microsoft OneDrive).
   258  
   259  #### --onedrive-client-id
   260  
   261  OAuth Client Id.
   262  
   263  Leave blank normally.
   264  
   265  Properties:
   266  
   267  - Config:      client_id
   268  - Env Var:     RCLONE_ONEDRIVE_CLIENT_ID
   269  - Type:        string
   270  - Required:    false
   271  
   272  #### --onedrive-client-secret
   273  
   274  OAuth Client Secret.
   275  
   276  Leave blank normally.
   277  
   278  Properties:
   279  
   280  - Config:      client_secret
   281  - Env Var:     RCLONE_ONEDRIVE_CLIENT_SECRET
   282  - Type:        string
   283  - Required:    false
   284  
   285  #### --onedrive-region
   286  
   287  Choose national cloud region for OneDrive.
   288  
   289  Properties:
   290  
   291  - Config:      region
   292  - Env Var:     RCLONE_ONEDRIVE_REGION
   293  - Type:        string
   294  - Default:     "global"
   295  - Examples:
   296      - "global"
   297          - Microsoft Cloud Global
   298      - "us"
   299          - Microsoft Cloud for US Government
   300      - "de"
   301          - Microsoft Cloud Germany
   302      - "cn"
   303          - Azure and Office 365 operated by Vnet Group in China
   304  
   305  ### Advanced options
   306  
   307  Here are the Advanced options specific to onedrive (Microsoft OneDrive).
   308  
   309  #### --onedrive-token
   310  
   311  OAuth Access Token as a JSON blob.
   312  
   313  Properties:
   314  
   315  - Config:      token
   316  - Env Var:     RCLONE_ONEDRIVE_TOKEN
   317  - Type:        string
   318  - Required:    false
   319  
   320  #### --onedrive-auth-url
   321  
   322  Auth server URL.
   323  
   324  Leave blank to use the provider defaults.
   325  
   326  Properties:
   327  
   328  - Config:      auth_url
   329  - Env Var:     RCLONE_ONEDRIVE_AUTH_URL
   330  - Type:        string
   331  - Required:    false
   332  
   333  #### --onedrive-token-url
   334  
   335  Token server url.
   336  
   337  Leave blank to use the provider defaults.
   338  
   339  Properties:
   340  
   341  - Config:      token_url
   342  - Env Var:     RCLONE_ONEDRIVE_TOKEN_URL
   343  - Type:        string
   344  - Required:    false
   345  
   346  #### --onedrive-chunk-size
   347  
   348  Chunk size to upload files with - must be multiple of 320k (327,680 bytes).
   349  
   350  Above this size files will be chunked - must be multiple of 320k (327,680 bytes) and
   351  should not exceed 250M (262,144,000 bytes) else you may encounter \"Microsoft.SharePoint.Client.InvalidClientQueryException: The request message is too big.\"
   352  Note that the chunks will be buffered into memory.
   353  
   354  Properties:
   355  
   356  - Config:      chunk_size
   357  - Env Var:     RCLONE_ONEDRIVE_CHUNK_SIZE
   358  - Type:        SizeSuffix
   359  - Default:     10Mi
   360  
   361  #### --onedrive-drive-id
   362  
   363  The ID of the drive to use.
   364  
   365  Properties:
   366  
   367  - Config:      drive_id
   368  - Env Var:     RCLONE_ONEDRIVE_DRIVE_ID
   369  - Type:        string
   370  - Required:    false
   371  
   372  #### --onedrive-drive-type
   373  
   374  The type of the drive (personal | business | documentLibrary).
   375  
   376  Properties:
   377  
   378  - Config:      drive_type
   379  - Env Var:     RCLONE_ONEDRIVE_DRIVE_TYPE
   380  - Type:        string
   381  - Required:    false
   382  
   383  #### --onedrive-root-folder-id
   384  
   385  ID of the root folder.
   386  
   387  This isn't normally needed, but in special circumstances you might
   388  know the folder ID that you wish to access but not be able to get
   389  there through a path traversal.
   390  
   391  
   392  Properties:
   393  
   394  - Config:      root_folder_id
   395  - Env Var:     RCLONE_ONEDRIVE_ROOT_FOLDER_ID
   396  - Type:        string
   397  - Required:    false
   398  
   399  #### --onedrive-access-scopes
   400  
   401  Set scopes to be requested by rclone.
   402  
   403  Choose or manually enter a custom space separated list with all scopes, that rclone should request.
   404  
   405  
   406  Properties:
   407  
   408  - Config:      access_scopes
   409  - Env Var:     RCLONE_ONEDRIVE_ACCESS_SCOPES
   410  - Type:        SpaceSepList
   411  - Default:     Files.Read Files.ReadWrite Files.Read.All Files.ReadWrite.All Sites.Read.All offline_access
   412  - Examples:
   413      - "Files.Read Files.ReadWrite Files.Read.All Files.ReadWrite.All Sites.Read.All offline_access"
   414          - Read and write access to all resources
   415      - "Files.Read Files.Read.All Sites.Read.All offline_access"
   416          - Read only access to all resources
   417      - "Files.Read Files.ReadWrite Files.Read.All Files.ReadWrite.All offline_access"
   418          - Read and write access to all resources, without the ability to browse SharePoint sites. 
   419          - Same as if disable_site_permission was set to true
   420  
   421  #### --onedrive-disable-site-permission
   422  
   423  Disable the request for Sites.Read.All permission.
   424  
   425  If set to true, you will no longer be able to search for a SharePoint site when
   426  configuring drive ID, because rclone will not request Sites.Read.All permission.
   427  Set it to true if your organization didn't assign Sites.Read.All permission to the
   428  application, and your organization disallows users to consent app permission
   429  request on their own.
   430  
   431  Properties:
   432  
   433  - Config:      disable_site_permission
   434  - Env Var:     RCLONE_ONEDRIVE_DISABLE_SITE_PERMISSION
   435  - Type:        bool
   436  - Default:     false
   437  
   438  #### --onedrive-expose-onenote-files
   439  
   440  Set to make OneNote files show up in directory listings.
   441  
   442  By default, rclone will hide OneNote files in directory listings because
   443  operations like "Open" and "Update" won't work on them.  But this
   444  behaviour may also prevent you from deleting them.  If you want to
   445  delete OneNote files or otherwise want them to show up in directory
   446  listing, set this option.
   447  
   448  Properties:
   449  
   450  - Config:      expose_onenote_files
   451  - Env Var:     RCLONE_ONEDRIVE_EXPOSE_ONENOTE_FILES
   452  - Type:        bool
   453  - Default:     false
   454  
   455  #### --onedrive-server-side-across-configs
   456  
   457  Deprecated: use --server-side-across-configs instead.
   458  
   459  Allow server-side operations (e.g. copy) to work across different onedrive configs.
   460  
   461  This will only work if you are copying between two OneDrive *Personal* drives AND
   462  the files to copy are already shared between them.  In other cases, rclone will
   463  fall back to normal copy (which will be slightly slower).
   464  
   465  Properties:
   466  
   467  - Config:      server_side_across_configs
   468  - Env Var:     RCLONE_ONEDRIVE_SERVER_SIDE_ACROSS_CONFIGS
   469  - Type:        bool
   470  - Default:     false
   471  
   472  #### --onedrive-list-chunk
   473  
   474  Size of listing chunk.
   475  
   476  Properties:
   477  
   478  - Config:      list_chunk
   479  - Env Var:     RCLONE_ONEDRIVE_LIST_CHUNK
   480  - Type:        int
   481  - Default:     1000
   482  
   483  #### --onedrive-no-versions
   484  
   485  Remove all versions on modifying operations.
   486  
   487  Onedrive for business creates versions when rclone uploads new files
   488  overwriting an existing one and when it sets the modification time.
   489  
   490  These versions take up space out of the quota.
   491  
   492  This flag checks for versions after file upload and setting
   493  modification time and removes all but the last version.
   494  
   495  **NB** Onedrive personal can't currently delete versions so don't use
   496  this flag there.
   497  
   498  
   499  Properties:
   500  
   501  - Config:      no_versions
   502  - Env Var:     RCLONE_ONEDRIVE_NO_VERSIONS
   503  - Type:        bool
   504  - Default:     false
   505  
   506  #### --onedrive-link-scope
   507  
   508  Set the scope of the links created by the link command.
   509  
   510  Properties:
   511  
   512  - Config:      link_scope
   513  - Env Var:     RCLONE_ONEDRIVE_LINK_SCOPE
   514  - Type:        string
   515  - Default:     "anonymous"
   516  - Examples:
   517      - "anonymous"
   518          - Anyone with the link has access, without needing to sign in.
   519          - This may include people outside of your organization.
   520          - Anonymous link support may be disabled by an administrator.
   521      - "organization"
   522          - Anyone signed into your organization (tenant) can use the link to get access.
   523          - Only available in OneDrive for Business and SharePoint.
   524  
   525  #### --onedrive-link-type
   526  
   527  Set the type of the links created by the link command.
   528  
   529  Properties:
   530  
   531  - Config:      link_type
   532  - Env Var:     RCLONE_ONEDRIVE_LINK_TYPE
   533  - Type:        string
   534  - Default:     "view"
   535  - Examples:
   536      - "view"
   537          - Creates a read-only link to the item.
   538      - "edit"
   539          - Creates a read-write link to the item.
   540      - "embed"
   541          - Creates an embeddable link to the item.
   542  
   543  #### --onedrive-link-password
   544  
   545  Set the password for links created by the link command.
   546  
   547  At the time of writing this only works with OneDrive personal paid accounts.
   548  
   549  
   550  Properties:
   551  
   552  - Config:      link_password
   553  - Env Var:     RCLONE_ONEDRIVE_LINK_PASSWORD
   554  - Type:        string
   555  - Required:    false
   556  
   557  #### --onedrive-hash-type
   558  
   559  Specify the hash in use for the backend.
   560  
   561  This specifies the hash type in use. If set to "auto" it will use the
   562  default hash which is QuickXorHash.
   563  
   564  Before rclone 1.62 an SHA1 hash was used by default for Onedrive
   565  Personal. For 1.62 and later the default is to use a QuickXorHash for
   566  all onedrive types. If an SHA1 hash is desired then set this option
   567  accordingly.
   568  
   569  From July 2023 QuickXorHash will be the only available hash for
   570  both OneDrive for Business and OneDriver Personal.
   571  
   572  This can be set to "none" to not use any hashes.
   573  
   574  If the hash requested does not exist on the object, it will be
   575  returned as an empty string which is treated as a missing hash by
   576  rclone.
   577  
   578  
   579  Properties:
   580  
   581  - Config:      hash_type
   582  - Env Var:     RCLONE_ONEDRIVE_HASH_TYPE
   583  - Type:        string
   584  - Default:     "auto"
   585  - Examples:
   586      - "auto"
   587          - Rclone chooses the best hash
   588      - "quickxor"
   589          - QuickXor
   590      - "sha1"
   591          - SHA1
   592      - "sha256"
   593          - SHA256
   594      - "crc32"
   595          - CRC32
   596      - "none"
   597          - None - don't use any hashes
   598  
   599  #### --onedrive-av-override
   600  
   601  Allows download of files the server thinks has a virus.
   602  
   603  The onedrive/sharepoint server may check files uploaded with an Anti
   604  Virus checker. If it detects any potential viruses or malware it will
   605  block download of the file.
   606  
   607  In this case you will see a message like this
   608  
   609      server reports this file is infected with a virus - use --onedrive-av-override to download anyway: Infected (name of virus): 403 Forbidden: 
   610  
   611  If you are 100% sure you want to download this file anyway then use
   612  the --onedrive-av-override flag, or av_override = true in the config
   613  file.
   614  
   615  
   616  Properties:
   617  
   618  - Config:      av_override
   619  - Env Var:     RCLONE_ONEDRIVE_AV_OVERRIDE
   620  - Type:        bool
   621  - Default:     false
   622  
   623  #### --onedrive-delta
   624  
   625  If set rclone will use delta listing to implement recursive listings.
   626  
   627  If this flag is set the onedrive backend will advertise `ListR`
   628  support for recursive listings.
   629  
   630  Setting this flag speeds up these things greatly:
   631  
   632      rclone lsf -R onedrive:
   633      rclone size onedrive:
   634      rclone rc vfs/refresh recursive=true
   635  
   636  **However** the delta listing API **only** works at the root of the
   637  drive. If you use it not at the root then it recurses from the root
   638  and discards all the data that is not under the directory you asked
   639  for. So it will be correct but may not be very efficient.
   640  
   641  This is why this flag is not set as the default.
   642  
   643  As a rule of thumb if nearly all of your data is under rclone's root
   644  directory (the `root/directory` in `onedrive:root/directory`) then
   645  using this flag will be be a big performance win. If your data is
   646  mostly not under the root then using this flag will be a big
   647  performance loss.
   648  
   649  It is recommended if you are mounting your onedrive at the root
   650  (or near the root when using crypt) and using rclone `rc vfs/refresh`.
   651  
   652  
   653  Properties:
   654  
   655  - Config:      delta
   656  - Env Var:     RCLONE_ONEDRIVE_DELTA
   657  - Type:        bool
   658  - Default:     false
   659  
   660  #### --onedrive-metadata-permissions
   661  
   662  Control whether permissions should be read or written in metadata.
   663  
   664  Reading permissions metadata from files can be done quickly, but it
   665  isn't always desirable to set the permissions from the metadata.
   666  
   667  
   668  Properties:
   669  
   670  - Config:      metadata_permissions
   671  - Env Var:     RCLONE_ONEDRIVE_METADATA_PERMISSIONS
   672  - Type:        Bits
   673  - Default:     off
   674  - Examples:
   675      - "off"
   676          - Do not read or write the value
   677      - "read"
   678          - Read the value only
   679      - "write"
   680          - Write the value only
   681      - "read,write"
   682          - Read and Write the value.
   683  
   684  #### --onedrive-encoding
   685  
   686  The encoding for the backend.
   687  
   688  See the [encoding section in the overview](/overview/#encoding) for more info.
   689  
   690  Properties:
   691  
   692  - Config:      encoding
   693  - Env Var:     RCLONE_ONEDRIVE_ENCODING
   694  - Type:        Encoding
   695  - Default:     Slash,LtGt,DoubleQuote,Colon,Question,Asterisk,Pipe,BackSlash,Del,Ctl,LeftSpace,LeftTilde,RightSpace,RightPeriod,InvalidUtf8,Dot
   696  
   697  #### --onedrive-description
   698  
   699  Description of the remote
   700  
   701  Properties:
   702  
   703  - Config:      description
   704  - Env Var:     RCLONE_ONEDRIVE_DESCRIPTION
   705  - Type:        string
   706  - Required:    false
   707  
   708  ### Metadata
   709  
   710  OneDrive supports System Metadata (not User Metadata, as of this writing) for
   711  both files and directories. Much of the metadata is read-only, and there are some
   712  differences between OneDrive Personal and Business (see table below for
   713  details).
   714  
   715  Permissions are also supported, if `--onedrive-metadata-permissions` is set. The
   716  accepted values for `--onedrive-metadata-permissions` are `read`, `write`,
   717  `read,write`, and `off` (the default). `write` supports adding new permissions,
   718  updating the "role" of existing permissions, and removing permissions. Updating
   719  and removing require the Permission ID to be known, so it is recommended to use
   720  `read,write` instead of `write` if you wish to update/remove permissions.
   721  
   722  Permissions are read/written in JSON format using the same schema as the
   723  [OneDrive API](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/resources/permission?view=odsp-graph-online),
   724  which differs slightly between OneDrive Personal and Business.
   725  
   726  Example for OneDrive Personal:
   727  ```json
   728  [
   729  	{
   730  		"id": "1234567890ABC!123",
   731  		"grantedTo": {
   732  			"user": {
   733  				"id": "ryan@contoso.com"
   734  			},
   735  			"application": {},
   736  			"device": {}
   737  		},
   738  		"invitation": {
   739  			"email": "ryan@contoso.com"
   740  		},
   741  		"link": {
   742  			"webUrl": "https://1drv.ms/t/s!1234567890ABC"
   743  		},
   744  		"roles": [
   745  			"read"
   746  		],
   747  		"shareId": "s!1234567890ABC"
   748  	}
   749  ]
   750  ```
   751  
   752  Example for OneDrive Business:
   753  ```json
   754  [
   755  	{
   756  		"id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
   757  		"grantedToIdentities": [
   758  			{
   759  				"user": {
   760  					"displayName": "ryan@contoso.com"
   761  				},
   762  				"application": {},
   763  				"device": {}
   764  			}
   765  		],
   766  		"link": {
   767  			"type": "view",
   768  			"scope": "users",
   769  			"webUrl": "https://contoso.sharepoint.com/:w:/t/design/a577ghg9hgh737613bmbjf839026561fmzhsr85ng9f3hjck2t5s"
   770  		},
   771  		"roles": [
   772  			"read"
   773  		],
   774  		"shareId": "u!LKj1lkdlals90j1nlkascl"
   775  	},
   776  	{
   777  		"id": "5D33DD65C6932946",
   778  		"grantedTo": {
   779  			"user": {
   780  				"displayName": "John Doe",
   781  				"id": "efee1b77-fb3b-4f65-99d6-274c11914d12"
   782  			},
   783  			"application": {},
   784  			"device": {}
   785  		},
   786  		"roles": [
   787  			"owner"
   788  		],
   789  		"shareId": "FWxc1lasfdbEAGM5fI7B67aB5ZMPDMmQ11U"
   790  	}
   791  ]
   792  ```
   793  
   794  To write permissions, pass in a "permissions" metadata key using this same
   795  format. The [`--metadata-mapper`](https://rclone.org/docs/#metadata-mapper) tool can
   796  be very helpful for this.
   797  
   798  When adding permissions, an email address can be provided in the `User.ID` or
   799  `DisplayName` properties of `grantedTo` or `grantedToIdentities`. Alternatively,
   800  an ObjectID can be provided in `User.ID`. At least one valid recipient must be
   801  provided in order to add a permission for a user. Creating a Public Link is also
   802  supported, if `Link.Scope` is set to `"anonymous"`.
   803  
   804  Example request to add a "read" permission:
   805  
   806  ```json
   807  [
   808  	{
   809  			"id": "",
   810  			"grantedTo": {
   811  					"user": {},
   812  					"application": {},
   813  					"device": {}
   814  			},
   815  			"grantedToIdentities": [
   816  					{
   817  							"user": {
   818  									"id": "ryan@contoso.com"
   819  							},
   820  							"application": {},
   821  							"device": {}
   822  					}
   823  			],
   824  			"roles": [
   825  					"read"
   826  			]
   827  	}
   828  ]
   829  ```
   830  
   831  Note that adding a permission can fail if a conflicting permission already
   832  exists for the file/folder.
   833  
   834  To update an existing permission, include both the Permission ID and the new
   835  `roles` to be assigned. `roles` is the only property that can be changed.
   836  
   837  To remove permissions, pass in a blob containing only the permissions you wish
   838  to keep (which can be empty, to remove all.)
   839  
   840  Note that both reading and writing permissions requires extra API calls, so if
   841  you don't need to read or write permissions it is recommended to omit
   842  `--onedrive-metadata-permissions`.
   843  
   844  Metadata and permissions are supported for Folders (directories) as well as
   845  Files. Note that setting the `mtime` or `btime` on a Folder requires one extra
   846  API call on OneDrive Business only.
   847  
   848  OneDrive does not currently support User Metadata. When writing metadata, only
   849  writeable system properties will be written -- any read-only or unrecognized keys
   850  passed in will be ignored.
   851  
   852  TIP: to see the metadata and permissions for any file or folder, run:
   853  
   854  ```
   855  rclone lsjson remote:path --stat -M --onedrive-metadata-permissions read
   856  ```
   857  
   858  Here are the possible system metadata items for the onedrive backend.
   859  
   860  | Name | Help | Type | Example | Read Only |
   861  |------|------|------|---------|-----------|
   862  | btime | Time of file birth (creation) with S accuracy (mS for OneDrive Personal). | RFC 3339 | 2006-01-02T15:04:05Z | N |
   863  | content-type | The MIME type of the file. | string | text/plain | **Y** |
   864  | created-by-display-name | Display name of the user that created the item. | string | John Doe | **Y** |
   865  | created-by-id | ID of the user that created the item. | string | 48d31887-5fad-4d73-a9f5-3c356e68a038 | **Y** |
   866  | description | A short description of the file. Max 1024 characters. Only supported for OneDrive Personal. | string | Contract for signing | N |
   867  | id | The unique identifier of the item within OneDrive. | string | 01BYE5RZ6QN3ZWBTUFOFD3GSPGOHDJD36K | **Y** |
   868  | last-modified-by-display-name | Display name of the user that last modified the item. | string | John Doe | **Y** |
   869  | last-modified-by-id | ID of the user that last modified the item. | string | 48d31887-5fad-4d73-a9f5-3c356e68a038 | **Y** |
   870  | malware-detected | Whether OneDrive has detected that the item contains malware. | boolean | true | **Y** |
   871  | mtime | Time of last modification with S accuracy (mS for OneDrive Personal). | RFC 3339 | 2006-01-02T15:04:05Z | N |
   872  | package-type | If present, indicates that this item is a package instead of a folder or file. Packages are treated like files in some contexts and folders in others. | string | oneNote | **Y** |
   873  | permissions | Permissions in a JSON dump of OneDrive format. Enable with --onedrive-metadata-permissions. Properties: id, grantedTo, grantedToIdentities, invitation, inheritedFrom, link, roles, shareId | JSON | {} | N |
   874  | shared-by-id | ID of the user that shared the item (if shared). | string | 48d31887-5fad-4d73-a9f5-3c356e68a038 | **Y** |
   875  | shared-owner-id | ID of the owner of the shared item (if shared). | string | 48d31887-5fad-4d73-a9f5-3c356e68a038 | **Y** |
   876  | shared-scope | If shared, indicates the scope of how the item is shared: anonymous, organization, or users. | string | users | **Y** |
   877  | shared-time | Time when the item was shared, with S accuracy (mS for OneDrive Personal). | RFC 3339 | 2006-01-02T15:04:05Z | **Y** |
   878  | utime | Time of upload with S accuracy (mS for OneDrive Personal). | RFC 3339 | 2006-01-02T15:04:05Z | **Y** |
   879  
   880  See the [metadata](/docs/#metadata) docs for more info.
   881  
   882  {{< rem autogenerated options stop >}}
   883  
   884  ## Limitations
   885  
   886  If you don't use rclone for 90 days the refresh token will
   887  expire. This will result in authorization problems. This is easy to
   888  fix by running the `rclone config reconnect remote:` command to get a
   889  new token and refresh token.
   890  
   891  ### Naming
   892  
   893  Note that OneDrive is case insensitive so you can't have a
   894  file called "Hello.doc" and one called "hello.doc".
   895  
   896  There are quite a few characters that can't be in OneDrive file
   897  names.  These can't occur on Windows platforms, but on non-Windows
   898  platforms they are common.  Rclone will map these names to and from an
   899  identical looking unicode equivalent.  For example if a file has a `?`
   900  in it will be mapped to `?` instead.
   901  
   902  ### File sizes
   903  
   904  The largest allowed file size is 250 GiB for both OneDrive Personal and OneDrive for Business [(Updated 13 Jan 2021)](https://support.microsoft.com/en-us/office/invalid-file-names-and-file-types-in-onedrive-and-sharepoint-64883a5d-228e-48f5-b3d2-eb39e07630fa?ui=en-us&rs=en-us&ad=us#individualfilesize).
   905  
   906  ### Path length
   907  
   908  The entire path, including the file name, must contain fewer than 400 characters for OneDrive, OneDrive for Business and SharePoint Online. If you are encrypting file and folder names with rclone, you may want to pay attention to this limitation because the encrypted names are typically longer than the original ones.
   909  
   910  ### Number of files
   911  
   912  OneDrive seems to be OK with at least 50,000 files in a folder, but at
   913  100,000 rclone will get errors listing the directory like `couldn’t
   914  list files: UnknownError:`.  See
   915  [#2707](https://github.com/artpar/artpar/issues/2707) for more info.
   916  
   917  An official document about the limitations for different types of OneDrive can be found [here](https://support.office.com/en-us/article/invalid-file-names-and-file-types-in-onedrive-onedrive-for-business-and-sharepoint-64883a5d-228e-48f5-b3d2-eb39e07630fa).
   918  
   919  ## Versions
   920  
   921  Every change in a file OneDrive causes the service to create a new
   922  version of the file.  This counts against a users quota.  For
   923  example changing the modification time of a file creates a second
   924  version, so the file apparently uses twice the space.
   925  
   926  For example the `copy` command is affected by this as rclone copies
   927  the file and then afterwards sets the modification time to match the
   928  source file which uses another version.
   929  
   930  You can use the `rclone cleanup` command (see below) to remove all old
   931  versions.
   932  
   933  Or you can set the `no_versions` parameter to `true` and rclone will
   934  remove versions after operations which create new versions. This takes
   935  extra transactions so only enable it if you need it.
   936  
   937  **Note** At the time of writing Onedrive Personal creates versions
   938  (but not for setting the modification time) but the API for removing
   939  them returns "API not found" so cleanup and `no_versions` should not
   940  be used on Onedrive Personal.
   941  
   942  ### Disabling versioning
   943  
   944  Starting October 2018, users will no longer be able to
   945  disable versioning by default. This is because Microsoft has brought
   946  an
   947  [update](https://techcommunity.microsoft.com/t5/Microsoft-OneDrive-Blog/New-Updates-to-OneDrive-and-SharePoint-Team-Site-Versioning/ba-p/204390)
   948  to the mechanism. To change this new default setting, a PowerShell
   949  command is required to be run by a SharePoint admin. If you are an
   950  admin, you can run these commands in PowerShell to change that
   951  setting:
   952  
   953  1. `Install-Module -Name Microsoft.Online.SharePoint.PowerShell` (in case you haven't installed this already)
   954  2. `Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking`
   955  3. `Connect-SPOService -Url https://YOURSITE-admin.sharepoint.com -Credential YOU@YOURSITE.COM` (replacing `YOURSITE`, `YOU`, `YOURSITE.COM` with the actual values; this will prompt for your credentials)
   956  4. `Set-SPOTenant -EnableMinimumVersionRequirement $False`
   957  5. `Disconnect-SPOService` (to disconnect from the server)
   958  
   959  *Below are the steps for normal users to disable versioning. If you don't see the "No Versioning" option, make sure the above requirements are met.*
   960  
   961  User [Weropol](https://github.com/Weropol) has found a method to disable
   962  versioning on OneDrive
   963  
   964  1. Open the settings menu by clicking on the gear symbol at the top of the OneDrive Business page.
   965  2. Click Site settings.
   966  3. Once on the Site settings page, navigate to Site Administration > Site libraries and lists.
   967  4. Click Customize "Documents".
   968  5. Click General Settings > Versioning Settings.
   969  6. Under Document Version History select the option No versioning.
   970  Note: This will disable the creation of new file versions, but will not remove any previous versions. Your documents are safe.
   971  7. Apply the changes by clicking OK.
   972  8. Use rclone to upload or modify files. (I also use the --no-update-modtime flag)
   973  9. Restore the versioning settings after using rclone. (Optional)
   974  
   975  ## Cleanup
   976  
   977  OneDrive supports `rclone cleanup` which causes rclone to look through
   978  every file under the path supplied and delete all version but the
   979  current version. Because this involves traversing all the files, then
   980  querying each file for versions it can be quite slow. Rclone does
   981  `--checkers` tests in parallel. The command also supports `--interactive`/`i`
   982  or `--dry-run` which is a great way to see what it would do.
   983  
   984      rclone cleanup --interactive remote:path/subdir # interactively remove all old version for path/subdir
   985      rclone cleanup remote:path/subdir               # unconditionally remove all old version for path/subdir
   986  
   987  **NB** Onedrive personal can't currently delete versions
   988  
   989  ## Troubleshooting ##
   990  
   991  ### Excessive throttling or blocked on SharePoint
   992  
   993  If you experience excessive throttling or is being blocked on SharePoint then it may help to set the user agent explicitly with a flag like this: `--user-agent "ISV|rclone.org|rclone/v1.55.1"`
   994  
   995  The specific details can be found in the Microsoft document: [Avoid getting throttled or blocked in SharePoint Online](https://docs.microsoft.com/en-us/sharepoint/dev/general-development/how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online#how-to-decorate-your-http-traffic-to-avoid-throttling)
   996  
   997  ### Unexpected file size/hash differences on Sharepoint ####
   998  
   999  It is a
  1000  [known](https://github.com/OneDrive/onedrive-api-docs/issues/935#issuecomment-441741631)
  1001  issue that Sharepoint (not OneDrive or OneDrive for Business) silently modifies
  1002  uploaded files, mainly Office files (.docx, .xlsx, etc.), causing file size and
  1003  hash checks to fail. There are also other situations that will cause OneDrive to
  1004  report inconsistent file sizes. To use rclone with such
  1005  affected files on Sharepoint, you
  1006  may disable these checks with the following command line arguments:
  1007  
  1008  ```
  1009  --ignore-checksum --ignore-size
  1010  ```
  1011  
  1012  Alternatively, if you have write access to the OneDrive files, it may be possible
  1013  to fix this problem for certain files, by attempting the steps below.
  1014  Open the web interface for [OneDrive](https://onedrive.live.com) and find the
  1015  affected files (which will be in the error messages/log for rclone). Simply click on
  1016  each of these files, causing OneDrive to open them on the web. This will cause each
  1017  file to be converted in place to a format that is functionally equivalent
  1018  but which will no longer trigger the size discrepancy. Once all problematic files
  1019  are converted you will no longer need the ignore options above.
  1020  
  1021  ### Replacing/deleting existing files on Sharepoint gets "item not found" ####
  1022  
  1023  It is a [known](https://github.com/OneDrive/onedrive-api-docs/issues/1068) issue
  1024  that Sharepoint (not OneDrive or OneDrive for Business) may return "item not
  1025  found" errors when users try to replace or delete uploaded files; this seems to
  1026  mainly affect Office files (.docx, .xlsx, etc.) and web files (.html, .aspx, etc.). As a workaround, you may use
  1027  the `--backup-dir <BACKUP_DIR>` command line argument so rclone moves the
  1028  files to be replaced/deleted into a given backup directory (instead of directly
  1029  replacing/deleting them). For example, to instruct rclone to move the files into
  1030  the directory `rclone-backup-dir` on backend `mysharepoint`, you may use:
  1031  
  1032  ```
  1033  --backup-dir mysharepoint:rclone-backup-dir
  1034  ```
  1035  
  1036  ### access\_denied (AADSTS65005) ####
  1037  
  1038  ```
  1039  Error: access_denied
  1040  Code: AADSTS65005
  1041  Description: Using application 'rclone' is currently not supported for your organization [YOUR_ORGANIZATION] because it is in an unmanaged state. An administrator needs to claim ownership of the company by DNS validation of [YOUR_ORGANIZATION] before the application rclone can be provisioned.
  1042  ```
  1043  
  1044  This means that rclone can't use the OneDrive for Business API with your account. You can't do much about it, maybe write an email to your admins.
  1045  
  1046  However, there are other ways to interact with your OneDrive account. Have a look at the WebDAV backend: https://rclone.org/webdav/#sharepoint
  1047  
  1048  ### invalid\_grant (AADSTS50076) ####
  1049  
  1050  ```
  1051  Error: invalid_grant
  1052  Code: AADSTS50076
  1053  Description: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access '...'.
  1054  ```
  1055  
  1056  If you see the error above after enabling multi-factor authentication for your account, you can fix it by refreshing your OAuth refresh token. To do that, run `rclone config`, and choose to edit your OneDrive backend. Then, you don't need to actually make any changes until you reach this question: `Already have a token - refresh?`. For this question, answer `y` and go through the process to refresh your token, just like the first time the backend is configured. After this, rclone should work again for this backend.
  1057  
  1058  ### Invalid request when making public links ####
  1059  
  1060  On Sharepoint and OneDrive for Business, `rclone link` may return an "Invalid
  1061  request" error. A possible cause is that the organisation admin didn't allow
  1062  public links to be made for the organisation/sharepoint library. To fix the
  1063  permissions as an admin, take a look at the docs:
  1064  [1](https://docs.microsoft.com/en-us/sharepoint/turn-external-sharing-on-or-off),
  1065  [2](https://support.microsoft.com/en-us/office/set-up-and-manage-access-requests-94b26e0b-2822-49d4-929a-8455698654b3).
  1066  
  1067  ### Can not access `Shared` with me files
  1068  
  1069  Shared with me files is not supported by rclone [currently](https://github.com/artpar/artpar/issues/4062), but there is a workaround:
  1070  
  1071  1. Visit [https://onedrive.live.com](https://onedrive.live.com/)
  1072  2. Right click a item in `Shared`, then click `Add shortcut to My files` in the context
  1073      ![make_shortcut](https://user-images.githubusercontent.com/60313789/206118040-7e762b3b-aa61-41a1-8649-cc18889f3572.png "Screenshot (Shared with me)")
  1074  3. The shortcut will appear in `My files`, you can access it with rclone, it behaves like a normal folder/file.
  1075      ![in_my_files](https://i.imgur.com/0S8H3li.png "Screenshot (My Files)")
  1076      ![rclone_mount](https://i.imgur.com/2Iq66sW.png "Screenshot (rclone mount)")
  1077  
  1078  ### Live Photos uploaded from iOS (small video clips in .heic files)
  1079  
  1080  The iOS OneDrive app introduced [upload and storage](https://techcommunity.microsoft.com/t5/microsoft-onedrive-blog/live-photos-come-to-onedrive/ba-p/1953452) 
  1081  of [Live Photos](https://support.apple.com/en-gb/HT207310) in 2020. 
  1082  The usage and download of these uploaded Live Photos is unfortunately still work-in-progress 
  1083  and this introduces several issues when copying, synchronising and mounting – both in rclone and in the native OneDrive client on Windows.
  1084  
  1085  The root cause can easily be seen if you locate one of your Live Photos in the OneDrive web interface. 
  1086  Then download the photo from the web interface. You will then see that the size of downloaded .heic file is smaller than the size displayed in the web interface. 
  1087  The downloaded file is smaller because it only contains a single frame (still photo) extracted from the Live Photo (movie) stored in OneDrive.
  1088  
  1089  The different sizes will cause `rclone copy/sync` to repeatedly recopy unmodified photos something like this:
  1090  
  1091      DEBUG : 20230203_123826234_iOS.heic: Sizes differ (src 4470314 vs dst 1298667)
  1092      DEBUG : 20230203_123826234_iOS.heic: sha1 = fc2edde7863b7a7c93ca6771498ac797f8460750 OK
  1093      INFO  : 20230203_123826234_iOS.heic: Copied (replaced existing)
  1094  
  1095  These recopies can be worked around by adding `--ignore-size`. Please note that this workaround only syncs the still-picture not the movie clip, 
  1096  and relies on modification dates being correctly updated on all files in all situations.
  1097  
  1098  The different sizes will also cause `rclone check` to report size errors something like this:
  1099  
  1100      ERROR : 20230203_123826234_iOS.heic: sizes differ
  1101  
  1102  These check errors can be suppressed by adding `--ignore-size`.
  1103  
  1104  The different sizes will also cause `rclone mount` to fail downloading with an error something like this:
  1105  
  1106      ERROR : 20230203_123826234_iOS.heic: ReadFileHandle.Read error: low level retry 1/10: unexpected EOF
  1107  
  1108  or like this when using `--cache-mode=full`:
  1109  
  1110      INFO  : 20230203_123826234_iOS.heic: vfs cache: downloader: error count now 1: vfs reader: failed to write to cache file: 416 Requested Range Not Satisfiable:
  1111      ERROR : 20230203_123826234_iOS.heic: vfs cache: failed to download: vfs reader: failed to write to cache file: 416 Requested Range Not Satisfiable: