How to reference a Collection item when creating a Custom Action

Hi,
Newby here and loving the tool!
I would like to know if is it possible to reference a Collection item when creating a Custom Action.
I created an entry on Users database to store a token and would like to use this token as the authentication for the Custom Action authorization when performing an API call.
Regards and tks!

Hi @virtcaio,

Welcome to the forum!

You can reference collection’s property values (items), but you need to have the data available on the screen. For example, if you have a “Shops” database, and would like to reference some shop’s address, you need to have “Current Shop” available on the screen.

However, for Users you have Logged-in User, which is available everywhere in the app. So if you have a “Token” field in “Users” collection, you can easily access it via Logged-in User → Token.

Then you can set up the custom action something like this:

Use some example token which will make the API call to be completed successfully.

And a final step - when you add this custom action to a button, you can use Logged-In User → Token as a parameter which you can pass to it.

This will be similar to screenshot below (another custom action, I pass email here)

Hope this helps.

Best regards, Victor.

1 Like

Great!
Thanks @Victor !
Questions:

  • How secure is store token and credentials at native Adalo databases?
  • I don’t see password option as a field when creating a new column for the database

Hi @virtcaio,

  • As for security - that depends on the threat model and risks. What will your user lose if the token is exposed? What are the chances for this token to become a “target” for hackers?

The tokens are stored in clear text mode, so anyone with an access to the app builder interface can see these tokens. Regular users don’t have access to this interface.

As for protection of the token in the app itself - I can’t really give a 100% reliable answer. I can’t see the way how native app could be hacked to steal the token (but may be it could?). Also I don’t know the exact way data is being transferred in the webapp.

There was an interesting discussion about possible ways to store tokens for cryptowallets here: Crypto API integration. It may not be related to your question directly but some posts were really useful.

  • Unfortunately, there is no “password” field type in Adalo Collections, except of the built-in one for Users collection.

Best regards, Victor.

1 Like