Requirements:
- php with zlib support
- files_external app must be enabled ❗
- Get the code
$ cd /server_path/apps
$ git clone https://github.com/cialtronale/files_external_onedrive
$ cd files_external_onedrive
$ composer install
- Activate the files_external app from NC settings page or cli
$ cd /server_path/
$ php -f occ app:enable files_external
- Activate files_external_onedrive from NC settings page or cli
$ cd /server_path/
$ php -f occ app:enable files_external_onedrive
- Fill up the storage details (See Below Configuring OAuth2)
- Fire up the files page to see the
OneDrive
mounted as external storage
Connecting OneDrive is a little more work because you have to create a onedrive app.
- Log into the https://portal.azure.com/ page and search App Registration
- Click New registration
- Name Your App
- Make sure to select:
Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
- For Redirect URL (optional) add the following URL
http://path/to/nextcloud/index.php/settings/user/externalstorages
(Replace http://path/to/nextcloud/index.php with you valid Nextcloud installation path, ensure that you don't leaveindex.php
in the path. Example:https://nextcloud.myserver.com/settings/admin/externalstorages
) - Click Register to create your app.
- Under the section Certificates and secrets add new client secret, Name, choose expires:never.
Make sure to copy the created key (you will not be able to do that later on). Key needs to be pasted in Nextcloud in last step
- Under the section API permissions
- Click add a permissions
- Choose Microsoft Graph, Delegated permissions
- add auth for [ User.Read | Files.ReadWrite.All | offline_access ] (the last is necessary to perform a correct token refresh)
- Copy Client Id and client secret then Go to Nextcloud
/settings/user/externalstorages
and Add a new storage OneDrive - Fill the details Client Id, Client Secrets from you onedrive App page
- Click Grant Access and then you will be redirected for OAuth login
- After completing the OAuth you will be redirect back to Storage Section and you should see green mark along your storage configuration
References: