OneDrive Adapter
Provides access to OneDrive (Personal) drives and files using SQL Server and REST commands.
This adapter requires advanced configuration with Azure AD and OAuth Configuration
OAuth Configuration
This adapter requires Azure AD and OAuth to be configured.
show steps-
Register an Application in Azure AD
Register an application with Microsoft Azure Directory using the Azure Portal (choose App Registrations, and select New Registration, and select Associate with Personal Account) https://portal.azure.com. Enter the Web redirect URL to https://localhost. -
Create an Application Secret
Locate the Application ID, Directory ID (Tenant ID), and create a new Application Secret (found under Certificates and Secrets). Copy the Secret in memory (this secret is only available when it is first created).
NOTE: If your login is used for both OneDrive and OneDrive for Business, you may need to update the Manifest of the application to use AzureADandPersonalMicrosoftAccount for the signInAudience setting. -
Assign all necessary rights
Select API Permissions for this application, and click Add Permissions (choose Microsoft Graph) and add the following Microsoft Graph permissions: Files.ReadAll, Files.WriteAll, Files.Read, Files.Write and offline_access. -
In Enzo Manager, create a Config Setting
Create a new Configuration Setting for OneDrive and save the secrets obtained above, along with the Tenant ID. -
Get the OAuth URL, and go through the authentication flow
Start SQL Server Management Studio, connect to Enzo directly, and execute the GetAuthURL handler. Copy and paste the URL provided, and go through the authentication flow. You will receive an error page saying 'This site can't be reached'; this is normal. Copy URL found in the URL bar (starting with https://localhost). -
Execute the GetToken handler and pass the URL above as an argument.
This call will return two values: AccessToken and RefreshToken. -
Update the Config Setting
Update the Config Settings with the above tokens.
Configuration Settings
Name | Description | Default |
---|---|---|
Boolean _isDefault | Make this the default configuration. Defaults to true if configName is already the default. | |
String appId | appId used for authentication | |
String clientSecret | clientSecret used for authentication | |
String accessToken | The accessToken used for authentication | |
String refreshToken | The refreshToken used for authentication of OneDrive api when expire accessToken |
Handlers
createFolder
folders |
Create new folder
details
Arguments
SQL CallEXEC OneDrive.createFolder @folderName='Test Folder' Http Call/bsc/onedrive/createfolder Output ColumnsThis call does not return data. |
||||||||||||||||||||||||||||||||||||
deleteFile
files |
Delete a file
details
Arguments
SQL CallEXEC OneDrive.deleteFile @fileId='fileid' Http Call/bsc/onedrive/deletefile Output ColumnsThis call does not return data. |
||||||||||||||||||||||||||||||||||||
deleteFolder
folders |
Delete a folder
details
Arguments
SQL CallEXEC OneDrive.deleteFolder @fileId='fileId' Http Call/bsc/onedrive/deletefolder Output ColumnsThis call does not return data. |
||||||||||||||||||||||||||||||||||||
downloadFile
file |
Download a file to a local or UNC path
details
Arguments
SQL CallEXEC OneDrive.downloadFile @id='fileId',@downloadPath='D:\download' Http Call/bsc/onedrive/downloadfile Output Columns
|
||||||||||||||||||||||||||||||||||||
GetAuthUrl
|
Get Auth Url
details
ArgumentsSQL Callexec OneDrive.GetAuthUrl Http Call/bsc/onedrive/getauthurl Output Columns
|
||||||||||||||||||||||||||||||||||||
GetToken
|
Get access token
details
Arguments
SQL Callexec OneDrive.GetToken 'responsecodeurl' Http Call/bsc/onedrive/gettoken Output Columns
|
||||||||||||||||||||||||||||||||||||
listFiles
files |
Returns the list of files/folders
details
Arguments
SQL Callexec OneDrive.listFiles Http Call/bsc/onedrive/listfiles Output Columns
|
||||||||||||||||||||||||||||||||||||
RefreshToken
|
Forces the creation of a new access token for the current logged in user
details
Arguments
SQL Callexec OneDrive.RefreshToken Http Call/bsc/onedrive/refreshtoken Output Columns
|
||||||||||||||||||||||||||||||||||||
renameFile
files |
Rename an existing file
details
Arguments
SQL CallEXEC OneDrive.renameFile @fileName='testFile.doc',@id='fileId' Http Call/bsc/onedrive/renamefile Output ColumnsThis call does not return data. |
||||||||||||||||||||||||||||||||||||
renameFolder
folders |
Rename an existing folder
details
Arguments
SQL CallEXEC OneDrive.renameFolder @fileName='test folder',@id='folderid' Http Call/bsc/onedrive/renamefolder Output ColumnsThis call does not return data. |
||||||||||||||||||||||||||||||||||||
uploadFile
file |
Upload a file to OneDrive
details
Arguments
SQL CallEXEC OneDrive.uploadFile @id='folderid',@sourceFile='D:\Download\A100.pdf',@fileName='A100.pdf' Http Call/bsc/onedrive/uploadfile Output ColumnsThis call does not return data. |