Actions with async metadata/custom claims

We’re using actions to add custom claims to the accessToken and the content of the claims are coming from either an API request or a MySQL query, but the problem is, I believe due to the async nature of the requests they’re not actually getting applied. I’ve got the following:

await runquery(event.user.user_metadata.i_account, async (acl_meta) => {


        if (acl_meta) {

            await api.accessToken.setCustomClaim(`https://metadata.client/acl`, acl_meta);




    var req = unirest('GET', '')

    .end(function (res) { 

        if (res.error) throw new Error(res.error); 


        var json = JSON.parse(res.raw_body)




Where runquery is a callback function of a MySQL query, though doing the same in the callback from the MySQL query i.e.:

await connection.query('SELECT bitflag FROM acl_accounts WHERE i_account=' + i_accont, function (error, results, fields) {    

Does not work either. I’ve tried with and without await, Anybody got any advice?


1 Like

Hi Joe,
have solved your problem? I think I might get a similar issue.

Best regards,

1 Like

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!