Question:
Why is the updateSecret() function giving permission error?
Product:
Wix Studio Editor
What are you trying to achieve:
I need to update a secret every 24 hours. I am following the dev documentation but I am getting the following error:
Failed to update Guesty API token: PERMISSION_DENIED: Permission denied, status: 403
What have you already tried:
I am in the backend files
Additional information:
// Function to set a new Guesty API token in Secrets Manager
export async function setGuestyToken() {
const secretId = ‘eba’; // Replace with your actual secret ID
const newToken = ‘123nfjen’
try {
// Update the secret with the new token
await wixSecretsBackend.updateSecret(secretId, { value: newToken });
console.log(‘Guesty API token updated successfully.’);
return { success: true, message: ‘Guesty API token updated successfully.’ };
} catch (error) {
console.error(‘Error updating the Guesty API token:’, error.message);
throw new Error(Failed to update Guesty API token: ${error.message}
);
}
}