Best way to integrate with another app via integration token?

What I’m trying to do:
Hi all, first time poster :slight_smile:

I’m building an app that queries a Notion database (notion.so). To achieve this, I created an integration token in Notion and use it for my API calls. I want to avoid hard-coding this integration token in the server code, so naturally I thought of the following options:

  1. Store it as a ‘secret’.
  2. Prompt the user for the integration token, encrypt, store in the database. Decrypt when needed for the API calls.

My current plan is to use Option 2 since I want this app to be usable by others. However, I wonder if there’s a more elegant way to do this. Specifically if there’s a UI akin to the attached image.

Thoughts?

1 Like

Looking through the API documentation for Notion, they have a very detailed step-by-step guide, on how to implement authorization to the API, using OAuth.

This would provide the flow we have all come to enjoy, where the end-user simply clicks a link, a page opens like the one in your screenshot, and they can log in, and grant access to their account.

The API documentation explains all this very well, so it should be relatively simple to implement this into your Anvil app.

Be sure to read through the documentation in details, as they provide some key points, on how to store the API tokens of your users.

1 Like