Twitch API - Request bearer token on every request?
Okay so I'm building a simple endpoint to grab the user ID of a user. In order to do so I need to provide a bearer token, which I get when I make a request for it using my client ID and secret.
Since I'm using serverless, will I really need to request that bearer token before every API request? Or am I missing obvious.
(I wish Twitch would let you make app API requests using your ID and secret directly)
7 Replies
You still have an instance underneath with lambdas, so you could keep your token in memory and just fetch if you happen to land on a fresh instance
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I'm using edge functions which afaik don't keep anything in memory, I should have been clearer considering 'Serverless' is a platform for aws
Yeah that will be the eventual setup but for now I guess there isn't a better way
ok yeah I think the isolates are destroyed between requests on edge
cloudflare?
deno deploy or netlify
depends how quickly ultra gets a netlify adaptor
I could probably spin up a dynamodb instance and store tokens there but that just saves making api calls to twitch - i'm still making the call somewhere
or redis/upstash
but if you're using edge you probably don't want to depend on a central region for that. I think vg has the right solution
Yep and that's what I'll do eventually, but for a poc this will be fine
Thanks @paul and @vgmestre