Hello,
I have been successfully using a method to convert OneDrive direct links into a Base64 encoded URL to share content via API, like this:
Original URL:
https://1drv.ms/t/c/b6a769b937e9eff3/EVtvodt7gEhKleFWNTy55vgBTFOziVeKp3kMvqG1wrrROA
Converted Base64 URL:
https://api.onedrive.com/v1.0/shares/u!aHR0cHM6Ly8xZHJ2Lm1zL3QvYy9iNmE3NjliOTM3ZTllZmYzL0VWdHZvZHQ3Z0VoS2xlRldOVHk1NXZnQlRGT3ppVmVLcDNrTXZxRzF3cnJST0E/root/
This was working fine previously. However, recently when I try to access the converted URL, I get the following error:
Error:
{"error":{"code":"unauthenticated","message":"Exception of type 'Microsoft.Vroom.Exceptions.UnauthenticatedVroomException' was thrown."}}
I'm using the following function to encode the URL into Base64:
function encodeBase64Url(url) {
const base64Encoded = btoa(url); // Base64 encode the URL
const base64Url = base64Encoded
.replace(/\+/g, '-') // Replace '+' with '-'
.replace(/\//g, '_') // Replace '/' with '_'
.replace(/=+$/, ''); // Remove '=' padding
return `u!${base64Url}`; // Add 'u!' prefix
}
const encodedUrl = encodeBase64Url(url);
// Create the download link
const downloadLink = https://api.onedrive.com/v1.0/shares/${encodedUrl}/root/content
;
Is there something wrong with my conversion process, or is there a different issue causing the error? Any help in resolving this would be greatly appreciated!