Skip to main content
Solved

Storing User-specific Tokens for Blocks

  • May 22, 2020
  • 9 replies
  • 42 views

Hey everybody! I’m starting development on a block for the hackathon – super exciting!
I’m going to need to store a unique token for each user, because I’m going to need to do some OAuth in my block.

I’m wondering the best approach to do this? I could store it in GlobalConfig, each token is accessible through the ID of the user, but I’m not sure about that. Any advice would be much appreciated!

I noticed this is done the demo for blocks, by storing the Twilio ID and Secret, so I’m curious how it’s done there

Best answer by Kasra

Hi Alec, welcome!

Here’s the code from the demo video. In that case, I was hard-coding the API keys into my code.

In our other blocks, for example the Map block and the Send SMS, we prompt the user for their API key and store it in globalConfig.

In these cases, we usually don’t store a token per user ID. The tokens are shared across all of the users who can access that block installation, which is nice because it means one person can set up the block in the base and then all of their base collaborators can use it.

9 replies

Forum|alt.badge.img+14
  • Inspiring
  • 47 replies
  • May 22, 2020

Hey Alec, which hackathon?


  • Author
  • New Participant
  • 3 replies
  • May 22, 2020

Hey Alec, which hackathon?



Forum|alt.badge.img+4
  • Inspiring
  • 192 replies
  • Answer
  • May 22, 2020

Hi Alec, welcome!

Here’s the code from the demo video. In that case, I was hard-coding the API keys into my code.

In our other blocks, for example the Map block and the Send SMS, we prompt the user for their API key and store it in globalConfig.

In these cases, we usually don’t store a token per user ID. The tokens are shared across all of the users who can access that block installation, which is nice because it means one person can set up the block in the base and then all of their base collaborators can use it.


  • Author
  • New Participant
  • 3 replies
  • May 22, 2020

Oh, I see! So it’s global across the collaborators in the base, not everyone who has installed your block?


Forum|alt.badge.img+4
  • Inspiring
  • 192 replies
  • May 22, 2020

Yep that’s right! globalConfig is scoped to the block installation. A block can be installed multiple times in the same base or across different bases, and each installation has its own distinct globalConfig storage.


Forum|alt.badge.img+3
  • Inspiring
  • 25 replies
  • May 24, 2020

Is it possible to do OAUTH with Airtable blocks ? What value are you providing for the return url after user grants access ?


  • Known Participant
  • 10 replies
  • May 24, 2020

+1 on the OAuth ask. :slightly_smiling_face: Ideally, my block would call a service I’m hosting and, from that service, one could update the original AirTable with the REST API. A bi-directional sync of sorts.

I can ask the user for their AirTable API token inside my block and pass a version of that along to my service, but that seems like it’d be frowned upon and less ideal than getting an OAuth token. Maybe asking for it in the block is ok for a MVP?

Any other ideas or feedback is welcome!


Forum|alt.badge.img+3
  • Inspiring
  • 25 replies
  • May 27, 2020

+1 on the OAuth ask. :slightly_smiling_face: Ideally, my block would call a service I’m hosting and, from that service, one could update the original AirTable with the REST API. A bi-directional sync of sorts.

I can ask the user for their AirTable API token inside my block and pass a version of that along to my service, but that seems like it’d be frowned upon and less ideal than getting an OAuth token. Maybe asking for it in the block is ok for a MVP?

Any other ideas or feedback is welcome!


I tried OAUTH with a pop up flow. But, it doesn’t work either because browsers don’t allow an iframe(custom blocks are in ifraMes) to communicate with another iframe(OAUTh popup).


Forum|alt.badge.img+13
  • Known Participant
  • 25 replies
  • May 27, 2020

+1 for Oauth2 Authorization Flow support, or t least “throwaway tokens” for specific Blocks, that would increase adoption by security-savvy users