Using JS in Actions to Manipulate Tokens

I am migrating my rules to actions and I am wondering how to the same thing I am doing in actions.

I first added the user’s app metadata to the token.
Then in the metadata I have a json array named databases. I want to remove all but 1 key that matches a specific key value.
Below code is how I did it in rules, in actions we use the setCustomClaim( function. What’s the best way to do the same thing?

context.accessToken[namespace + '/app_metadata'].databases = context.accessToken[namespace + '/app_metadata'].databases.filter((o) => o.dbKey === clavenKey);

Hey there!

As this topic is related to Actions and Rules & Hooks are being deprecated soon in favor of Actions, I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!