OneDrive File System Provider
- 2 minutes to read
The OneDrive file system provider (OneDriveFileSystemProvider) allows you to connect ASPxFileManager to OneDrive without user authentication.
Prerequisites
Register your application with Azure Active Directory to get an access token that sets permissions for your application. This also allows your application to use OneDrive APIs to work with the App Folder.
Note
Register your account in Azure and Office365 for Business to configure OneDrive Storage.
Select Azure Active Directory/App registrations and click New application registration.
Enter the application’s name, type, and sign-on URL, and click Create.
Click Endpoints to get the Token Endpoint and Authorization Endpoint.
Click Settings to access your application’s settings. Use the “Application ID” field value to specify the clientID parameter for the RegisterOneDrive(String, String, String) method.
Click Reply URLs to specify URLs to which Azure Active Directory sends the authentication responses.
Click Required permissions and then click Add to specify permissions for Microsoft Graph.
Click Keys to create the clientSecret key and then use it as a parameter for the RegisterOneDrive(String, String, String) method.
Provider Settings
Set the ASPxFileManager.ProviderType property to FileManagerProviderType.OneDrive to allow the file manager to manage files and folders in OneDrive’s App Folder.
The OneDriveFileSystemProvider class allows you to access the file and folder hierarchy, and manipulate these files in the file manager.
Do the following to connect ASPxFileManager to OneDrive:
Use the AccountManager.RegisterOneDrive method to register the OneDrive account in the global.asax file.
AccountManager.RegisterOneDrive("FileManagerOneDriveAccount", "f49c387c-1c25-4f27-855b-dfd3fd3", "..+SKN3n5H0/KZVb6c=...");
Use the ASPxFileManager.SettingsOneDrive property to specify the OneDrive account settings:
- FileManagerOneDriveProviderSettings.AccountName - Specifies the OneDrive account’s name.
- FileManagerOneDriveProviderSettings.RedirectUri - Specifies the URL to which the browser is redirected when authentication is complete.
- FileManagerOneDriveProviderSettings.TokenEndpoint - Specifies the URL that the application uses to get the token.
<dx:ASPxFileManager ID="FileManager" runat="server" ProviderType="OneDrive"> <SettingsOneDrive AccountName="FileManagerOneDriveAccount" TokenEndpoint="https://login.microsoftonline.com/{tenant}/oauth2/token" RedirectUri="http://mysite.com" /> ... </dx:ASPxFileManager>
ASPxFileManager allows you to handle every request to OneDrive (the ASPxFileManager.CloudProviderRequest event).