Sharefile signed url is randomly giving AuthenticationFailed error
Hi,
I am facing a random authentication failure error for each SAS URI that is being generated. I am using the NodeJs library @azure/storage-file-share. I couldn't find the pattern of why the error is happening, some generated URIs work using the same code, and others don't.
On the other hand, I tried to generate it using Azure Portal through "Shared access signature" and it worked perfectly, however; that's not a safe solution as it's preferable to be generated for no more than 24h.
My failing attempts to solve it:
- I added timezone, I know in the code it's static but this is only for development.
- change permission rights to
rwdlc - Try with different params (I think the issue is about params, but I still don't understand why it works randomly please if there is any explanation)
Thank you!
Code:
const fileClient = this.shareServiceClient
.getShareClient(this.shareName)
.getDirectoryClient(STORAGE_RESULT_PATH)
.getFileClient(fileName);
const timezoneOffset = +3 * 60;
const startDate = new Date();
const expiryDate = new Date(startDate);
expiryDate.setHours(startDate.getHours() + timezoneOffset + (24*60));
startDate.setMinutes(startDate.getMinutes() + timezoneOffset );
const downloadFileResponse = fileClient.generateSasUrl({
permissions: AccountSASPermissions.parse('r'),
expiresOn: expiryDate,
startsOn: startDate
});
Error and URI params for failing attempt:
Flow for error randomness: