# 400 - Parameters are messed up again? Refreshing Token

**URL:** <https://discuss.dev.twitch.com/t/400-parameters-are-messed-up-again-refreshing-token/13438>\
**Category:** API\
**Created:** [December 27, 2017, 2:42pm UTC](https://discuss.dev.twitch.com/t/400-parameters-are-messed-up-again-refreshing-token/13438 "2017-12-27T14:42:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aresak](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/aresak/32/3884_2.png) [@Aresak](https://discuss.dev.twitch.com/u/Aresak)\
**Post date:** [December 27, 2017, 2:42pm UTC](https://discuss.dev.twitch.com/t/400-parameters-are-messed-up-again-refreshing-token/13438/1 "2017-12-27T14:42:29Z")

</div>

When I send an POST request to the API, I receive an 400 error, but no more info like what is wrong.

The code:  
`Twitch::Post("https://api.twitch.tv/kraken/oauth2/token", array( "grant_type" => "refresh_token", "refresh_token" => Aresak::mysqli_result($result, $i, "extras"), "client_id" => Twitch::ClientID(), "client_secret" => Twitch::ClientSecret() ));`

I guess there are messed up parameters again. Like client\_id should be Client-ID etc., but I don’t know which are right as far as there is nothing in the documentation.

Post request in Php

---

<div class="post-metadata">

**Author:** ![3ventic](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/3ventic/32/298_2.png) [@3ventic](https://discuss.dev.twitch.com/u/3ventic)\
**Post date:** [December 27, 2017, 6:50pm UTC](https://discuss.dev.twitch.com/t/400-parameters-are-messed-up-again-refreshing-token/13438/2 "2017-12-27T18:50:58Z")

</div>

Do you log the request you make so you know your code is requesting the URL with the data in the format you’re expecting?

---

<div class="post-metadata">

**Author:** ![Aresak](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/aresak/32/3884_2.png) [@Aresak](https://discuss.dev.twitch.com/u/Aresak)\
**Post date:** [December 29, 2017, 9:51am UTC](https://discuss.dev.twitch.com/t/400-parameters-are-messed-up-again-refreshing-token/13438/3 "2017-12-29T09:51:36Z")

</div>

Yes, I know it is correct.

---

<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, 4:54am UTC](https://discuss.dev.twitch.com/t/400-parameters-are-messed-up-again-refreshing-token/13438/4 "2018-01-19T04:54:51Z")

</div>

Did you ever figure this out? I am getting “message”: “The parameter “grant\_type” was malformed: value must be one of “authorization\_code”, “password””. Is using the Refresh\_Token not supported? Then why make OAuth tokens invalid after 240 minutes?

---

<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:37am UTC](https://discuss.dev.twitch.com/t/400-parameters-are-messed-up-again-refreshing-token/13438/5 "2018-01-19T11:37:59Z")

</div>

Did you correctly follow the documentation:

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

> To refresh, use this request:

```
curl -X POST https://api.twitch.tv/kraken/oauth2/token 
    --data-urlencode
    ?grant_type=refresh_token
    &refresh_token=<your refresh token>
    &client_id=<your client ID>
    &client_secret=<your client secret>

```

Sounds like you have performed a GET request instead of a POST request

---

<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/400-parameters-are-messed-up-again-refreshing-token/13438/6 "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.
