# Access Tokens Expiration

**URL:** <https://discuss.dev.twitch.com/t/access-tokens-expiration/13609>\
**Category:** API\
**Created:** [January 10, 2018, 6:06pm UTC](https://discuss.dev.twitch.com/t/access-tokens-expiration/13609 "2018-01-10T18:06:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hadrien-DELAITRE](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/hadrien-delaitre/32/3944_2.png) [@Hadrien-DELAITRE](https://discuss.dev.twitch.com/u/Hadrien-DELAITRE)\
**Post date:** [January 10, 2018, 6:06pm UTC](https://discuss.dev.twitch.com/t/access-tokens-expiration/13609/1 "2018-01-10T18:06:12Z")

</div>

When i receive my `access_token` from authentication API point :

```
POST https://api.twitch.tv/kraken/oauth2/token
    ?client_id=uo6dggojyb8d6soh92zknwmi5ej1q2
    &client_secret=nyo51xcdrerl8z9m56w9w6wg
    &code=394a8bc98028f39660e53025de824134fb46313
    &grant_type=authorization_code
    &redirect_uri=http://localhost

```

Field `expires_in` returns a value ~ 15000.

I thought (reading old post) that access tokens never expire :

> [@Access tokens expire and refresh tokens](https://discuss.dev.twitch.com/t/access-tokens-expire-and-refresh-tokens/11227):
>
> Hi! This questions were asked few times already, but I can’t find answers for them in the doc: Does access token expire? Is there any use for refresh token? Thanks for your help!

And i don’t clearly read in v5 documentation the behavior about access tokens expiration.

So i have to implement a refresh-token solution in order to make an access token valid beyond the `expires_in` field or there is others solutions ?

And how this `expires_in` value is computed ?

---

<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:** [January 10, 2018, 6:09pm UTC](https://discuss.dev.twitch.com/t/access-tokens-expiration/13609/2 "2018-01-10T18:09:34Z")

</div>

> [@Hadrien-DELAITRE](#):
>
> So i have to implement a refresh-token solution in order to make an access token valid beyond the expires\_in field or there is others solutions ?

Yes.

Recently they changed the API.

If you have a ClientID created after a certain point, access tokens generated via that client now expire and you need to refresh.

At some point this change will be back ported to everyones ClientID

---

<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:** [January 10, 2018, 6:10pm UTC](https://discuss.dev.twitch.com/t/access-tokens-expiration/13609/3 "2018-01-10T18:10:06Z")

</div>

> [@Hadrien-DELAITRE](#):
>
> &client\_secret=nyo51xcdrerl8z9m56w9w6wg

If this is your Secret, you should revoke it immeditely

---

<div class="post-metadata">

**Author:** ![Hadrien-DELAITRE](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/hadrien-delaitre/32/3944_2.png) [@Hadrien-DELAITRE](https://discuss.dev.twitch.com/u/Hadrien-DELAITRE)\
**Post date:** [January 10, 2018, 6:21pm UTC](https://discuss.dev.twitch.com/t/access-tokens-expiration/13609/4 "2018-01-10T18:21:43Z")

</div>

Thanks, i took this secret from the example in the documentation 🙂

So let’s go for a refresh-token solution.

---

<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:** [January 10, 2018, 9:23pm UTC](https://discuss.dev.twitch.com/t/access-tokens-expiration/13609/5 "2018-01-10T21:23:20Z")

</div>

> [@Hadrien-DELAITRE](#):
>
> Thanks, i took this secret from the example in the documentation

Roger that, but best to keep to the “not posting secrets” just in case you forget next time 😃

---

<div class="post-metadata">

**Author:** ![dustinduse](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dustinduse/32/3347_2.png) [@dustinduse](https://discuss.dev.twitch.com/u/dustinduse)\
**Post date:** [January 19, 2018, 5:05am UTC](https://discuss.dev.twitch.com/t/access-tokens-expiration/13609/6 "2018-01-19T05:05:33Z")

</div>

Did you ever come to a solution? I attempted

```
https://api.twitch.tv/kraken/oauth2/token
?client_id=(INSERTID)
&client_secret=(INSERTSECRET)
&grant_type=refresh_token
&refresh_token=(INSERTTOKEN)

```

But Twitch returns:  
“The parameter “grant\_type” was malformed: value must be one of “authorization\_code”, “password””

---

<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:** [January 19, 2018, 11:38am UTC](https://discuss.dev.twitch.com/t/access-tokens-expiration/13609/7 "2018-01-19T11:38:05Z")

</div>

You necro-ed this thread and [400 - Parameters are messed up again? Refreshing Token](https://discuss.dev.twitch.com/t/400-parameters-are-messed-up-again-refreshing-token/13438/3) I will answer over on the other thread. Please start a new thread rather than necroing

---

<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:** [February 18, 2018, 11:38am UTC](https://discuss.dev.twitch.com/t/access-tokens-expiration/13609/8 "2018-02-18T11:38:14Z")

</div>

Closed on February 18, 2018, 11:38am UTC

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