# Long lived access token

**URL:** <https://staging-discuss.dev.twitch.com/t/long-lived-access-token/24985>\
**Category:** API\
**Created:** [April 14, 2020, 5:53pm UTC](https://staging-discuss.dev.twitch.com/t/long-lived-access-token/24985 "2020-04-14T17:53:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aoleynik](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/aoleynik/32/5907_2.png) [@aoleynik](https://staging-discuss.dev.twitch.com/u/aoleynik)\
**Post date:** [April 14, 2020, 5:53pm UTC](https://staging-discuss.dev.twitch.com/t/long-lived-access-token/24985/1 "2020-04-14T17:53:27Z")

</div>

Hello, is there any way to get long lived access token for chat bot?  
When I get token through [OAuth Authorization Code Flow](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth#oauth-authorization-code-flow) it will expire in an hour, but when I get it by [https://twitchapps.com/tmi/](https://twitchapps.com/tmi/) it seems that it lives much longer.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 14, 2020, 5:56pm UTC](https://staging-discuss.dev.twitch.com/t/long-lived-access-token/24985/2 "2020-04-14T17:56:20Z")

</div>

Generally speaking a user access token will last for four hours. (A single hour is odd…)

For a chat bot, the token is only checked for validity when you connect to Twitch. When the key dies your bot is not DC’ed

So use the refresh token to automate collecting a obtaining a new token, when your bot boots/reconnects to chat.

> **[Authentication](https://dev.twitch.tv/docs/authentication/)**
>
> Authentication

---

<div class="post-metadata">

**Author:** ![aoleynik](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/aoleynik/32/5907_2.png) [@aoleynik](https://staging-discuss.dev.twitch.com/u/aoleynik)\
**Post date:** [April 14, 2020, 6:02pm UTC](https://staging-discuss.dev.twitch.com/t/long-lived-access-token/24985/3 "2020-04-14T18:02:35Z")

</div>

You are right, it lives four hours, I got 3600 seconds from API documentation.  
Thank you!

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 14, 2020, 6:03pm UTC](https://staging-discuss.dev.twitch.com/t/long-lived-access-token/24985/4 "2020-04-14T18:03:24Z")

</div>

heh

Expirations might change/update at any time, so the docs were probably an example. The validaity endpoint and/or the token response will always give the up to date information

---

<div class="post-metadata">

**Author:** ![system](https://d2spem0quai2ol.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://staging-discuss.dev.twitch.com/u/system)\
**Post date:** [May 14, 2020, 6:03pm UTC](https://staging-discuss.dev.twitch.com/t/long-lived-access-token/24985/5 "2020-05-14T18:03:29Z")

</div>

Closed on May 14, 2020, 6:03pm UTC

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