Is it possible to access secrets in Actions outside of onExecutePostLogin function?

Hi there!

Is it possible to access secrets in Actions outside of onExecutePostLogin function definition? Inside the function we can access a secret by calling event.secrets.

Currently we initialize a client inside the function but that seems to be triggered on each user login (it’s a Login flow action). I want to move the client initialization outside but it requires reading the secrets.

Thanks!

1 Like

There are few ways you can achieve this:

  1. pass the secret value to the function as a parameter.
  2. use global variables and assign the secret value at the beginning (not recommended)

I hope it helps. :slight_smile:

1 Like

We initialize a third-party service client inside of onExecutePostLogin and it’s being initialized on each user login which might exceed the rate limit. I guess option number 1 is only one to go with but we would need to use api.cache.

We initialize this client in multiple actions. Is there a way in Auth0 to reuse some piece of code logic across multiple actions?

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!