You can copy a file from SharePoint Online by using the Web activity to authenticate and grab the access token from SPO, then passing it to the subsequent Copy data activity to copy the file with the HTTP connector as the source.
Follow the prerequisites to create AAD application and grant permission to SharePoint Online.
Web activity - GetBearerToken
Create a Web Activity to get the access token from SharePoint Online, name it "GetBearerToken"
General
- Secure Output
Settings
- URL: https://accounts.accesscontrol.windows.net/[Tenant-ID]/tokens/OAuth/2
Replace the tenant ID - Method: POST
- Headers:
- Content-Type: application/x-www-form-urlencoded
- Body: grant_type=client_credentials&client_id=[Client-ID]@[Tenant-ID]&client_secret=[Client-Secret]&resource=00000003-0000-0ff1-ce00-000000000000/[Tenant-Name].sharepoint.com@[Tenant-ID]
Replace the client ID (application ID), client secret (application key), tenant ID, and tenant name (of the SharePoint tenant)
Copy data - CopyDataFromSPO
Chain with a Copy activity with HTTP connector as source to copy SharePoint Online file content, name it "CopyDataFromSPO":
General
- Secure Input
Source
- HTTP Linked Service:
- Base URL: https://[site-url]/_api/web/GetFileByServerRelativeUrl('[relative-path-to-file]')/$value
Replace the site URL and relative path to file. Sample relative path to file as /sites/site2/Shared Documents/TestBook.xlsx - Authentication Type: Anonymous
(to use the Bearer token configured in copy activity source later) - Type: choose the format you want. To copy file as-is, select "Binary" type.
- Base URL: https://[site-url]/_api/web/GetFileByServerRelativeUrl('[relative-path-to-file]')/$value
- Request Method: GET
- Source Additional Headers: @{concat('Authorization: Bearer ', activity('GetBearerToken').output.access_token)}
Uses the Bearer token generated by the upstream Web activity as authorization header. Replace the Web activity name
Sink
- Configure the copy activity sink as usual