updateSecret() function

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});
}
}

There are some requirements associated to using the Wix Secrets Backend API:

  • You must set up a Members Area, before you can create or manage secrets with the Secrets API. The Members Area isn’t required to retrieve secrets with getSecret().
  • Deleting a secret, or modifying a secret’s name or value, breaks all code using the secret.
  • You can’t create or rename a secret with a name that’s already in use.

Are these requirements met?