# OAuth Authorization Code Flow Tokens expire after few hours

**URL:** <https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-tokens-expire-after-few-hours/20323>\
**Category:** API\
**Created:** [March 2, 2019, 12:53pm UTC](https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-tokens-expire-after-few-hours/20323 "2019-03-02T12:53:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon9409167](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@anon9409167](https://staging-discuss.dev.twitch.com/u/anon9409167)\
**Post date:** [March 2, 2019, 12:53pm UTC](https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-tokens-expire-after-few-hours/20323/1 "2019-03-02T12:53:21Z")

</div>

I currently try to understand the process of getting OAuth codes, which I need for my chatbot.  
I am doing it like it is described here: [https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#oauth-authorization-code-flow](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#oauth-authorization-code-flow)  
I get an access token and also the refresh token, but my expires\_in is only a few hours, where on 3rd party Token Webistes, Keys last for 60 days. How can I get the key to last 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:** [March 2, 2019, 12:55pm UTC](https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-tokens-expire-after-few-hours/20323/2 "2019-03-02T12:55:32Z")

</div>

You can’t

The 3rd party token websites use a legacy clientID.

Those will soon (TM VALVE TIME) also have a short `expires_in`

---

<div class="post-metadata">

**Author:** ![anon9409167](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@anon9409167](https://staging-discuss.dev.twitch.com/u/anon9409167)\
**Post date:** [March 2, 2019, 1:01pm UTC](https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-tokens-expire-after-few-hours/20323/3 "2019-03-02T13:01:58Z")

</div>

So how is it if a token expires while a PubSub connection is active? Does it get terminated and has to reopened with the new token?

---

<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:** [March 2, 2019, 1:13pm UTC](https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-tokens-expire-after-few-hours/20323/4 "2019-03-02T13:13:34Z")

</div>

> [@anon9409167](#):
>
> Does it get terminated and has to reopened with the new token?

Just like chat, currently it’s only checked when you connect to the service.

---

<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:** [April 1, 2019, 1:27pm UTC](https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-tokens-expire-after-few-hours/20323/5 "2019-04-01T13:27:34Z")

</div>

Closed on April 1, 2019, 1:27pm UTC

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