I need to store my API token (to be renewed every hour). The following code throws the error:
PERMISSION_DENIED: Permission denied, status: 403"
I have setup Members Area, secret_id is correct value.
export function SaveTokenForAlto(secret_id, token_id){
const secret = {
value: token_id,
};
return wixSecretsBackend
.updateSecret(secret_id, secret)
.then(() => {console.log("Secret updated");})
.catch((error) => {console.error(error);});}
It should update the secret value in the Wix secret manager.
Seems to be a bug. Use the v2 function instead with elevation:
import { secrets } from 'wix-secrets-backend.v2';
import {elevate} from 'wix-auth'
export function SaveTokenForAlto(secret_id, token_id) {
const secret = {
value: token_id,
};
const elevated = elevate(secrets.updateSecret)
return elevated(secret_id, secret)
.then(() => { console.log("Secret updated"); })
.catch((error) => { console.error(error); });
}