# Persisting App Access Token

**URL:** <https://discuss.dev.twitch.com/t/persisting-app-access-token/44710>\
**Category:** API\
**Created:** [April 2, 2023, 8:40pm UTC](https://discuss.dev.twitch.com/t/persisting-app-access-token/44710 "2023-04-02T20:40:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peepersoak](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/peepersoak/32/23759_2.png) [@Peepersoak](https://discuss.dev.twitch.com/u/Peepersoak)\
**Post date:** [April 2, 2023, 8:40pm UTC](https://discuss.dev.twitch.com/t/persisting-app-access-token/44710/1 "2023-04-02T20:40:59Z")

</div>

Hey,

So I’m currently creating a function to subscribe to real-time notification for Twitch.

The problem is, to subscribe to their notification, I need to set up a webhook callback which is almost done, but the thing is I need the app access token, now how would you persist this? or do I even need to persist this? like can I just generate a new app access token for every request I made?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 2, 2023, 8:43pm UTC](https://discuss.dev.twitch.com/t/persisting-app-access-token/44710/2 "2023-04-02T20:43:11Z")

</div>

I generate a token  
Store the token in redis  
And have a service check/remake it when needed and put it back into redis

Then when a thing needs app access it’ll grab it from redis.

I have multiple scripts/servers both cronjob/long form that need a token so I use redis to store the one token to rule them all and they all call from there

---

<div class="post-metadata">

**Author:** ![Peepersoak](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/peepersoak/32/23759_2.png) [@Peepersoak](https://discuss.dev.twitch.com/u/Peepersoak)\
**Post date:** [April 2, 2023, 8:48pm UTC](https://discuss.dev.twitch.com/t/persisting-app-access-token/44710/3 "2023-04-02T20:48:00Z")

</div>

I see, so I really need to persist it.

I’ll use the method you mention, I think that’s much better compared to my idea

Thank you

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 2, 2023, 8:49pm UTC](https://discuss.dev.twitch.com/t/persisting-app-access-token/44710/4 "2023-04-02T20:49:04Z")

</div>

_if_ you only have this one single thing that using a token.

Then generating each time is _ok_

It’s just considered bad practice.

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [May 2, 2023, 8:49pm UTC](https://discuss.dev.twitch.com/t/persisting-app-access-token/44710/5 "2023-05-02T20:49:13Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
