I have stumbled across the solution. Using HttpRequest you can get a download link that works when the user is logged out of Sharepoint.
Firstly thanks to @Reza Dorrani and his youtube video: https://www.youtube.com/watch?v=n3mhe88BI34
From this you can get the SiteID and DriveID. I have saved them to variables: varSPSiteID and varSPDriveID
Now the code in the download button onselect:
Office365Groups.HttpRequest("https://graph.microsoft.com/v1.0/sites/" & varSPSiteID & "/drives/" & varSPDriveID & "/root:/" & <Encodedfilepath>, "GET", "", {ContentType: "application/json"})
To get <Encodedfilepath>:
I use the Sharepoint ‘Full Path’ of a file. (I have made a Gallery1 connect to my SharePoint Library). Unfortunately this includes the library name which I remove using the mid function, counting the characters in the name:
Gallery1.Selected.’Full Path’ = SOPS/Forms & Templates/DEV-004 xxxx.pdf
varSPLibraryPathLength = 6
Mid(Gallery1.Selected.'Full Path', varSPLibraryPathLength, 500) = Forms & Templates/DEV-004 xxxx.pdf
This then needs encoding:
<Encodedfilepath> = EncodeUrl(Mid(Gallery1.Selected.'Full Path', varSPLibraryPathLength, 500)) =
Forms%20%26%20Templates%2FDEV-004%20xxxx.pdf
Now put the whole lot in a variable:
Set(varSPDownload,Office365Groups.HttpRequest("https://graph.microsoft.com/v1.0/sites/" & varSPSiteID & "/drives/" & varSPDriveID & "/root:/" & EncodeUrl(Mid(Gallery1.Selected.'Full Path', varSPLibraryPathLength, 500)), "GET", "", {ContentType: "application/json"}));
And then add as the next line:
Launch(Text(varSPDownload.'@microsoft.graph.downloadUrl'))
If you use the Microsoft graph alluded to in Reza’s video you can paste the output text (with the actual siteid and driveid) of the HttpRequest into that and then you can see other details you could pull out (you will see the download link):
https://graph.microsoft.com.......Forms%20%26%20Templates%2FDEV-004%20xxxx.pdf
Hopefully someone can figure this out/useful