# OAuth authorization code flow isnt working

**URL:** <https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-isnt-working/29665>\
**Category:** API\
**Created:** [December 27, 2020, 4:38pm UTC](https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-isnt-working/29665 "2020-12-27T16:38:18Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![Diego\_Fernandez](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/diego_fernandez/32/10993_2.png) [@Diego\_Fernandez](https://staging-discuss.dev.twitch.com/u/Diego_Fernandez)\
**Post date:** [December 27, 2020, 6:00pm UTC](https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-isnt-working/29665/21 "2020-12-27T18:00:39Z")

</div>

And how can I get only the access token without the long text?

---

<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:** [December 27, 2020, 6:01pm UTC](https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-isnt-working/29665/22 "2020-12-27T18:01:05Z")

</div>

> [@BarryCarlyon](#):
>
> Instide the response to the curl request.
> 
> It’ll need to be JSON decoded and then you can exract it from the object
> 
> My JSON Decode is here
> 
> [github.com](https://github.com/BarryCarlyon/twitch_misc/blob/master/authentication/user_access_generator/php/index.php#L57)
> 
> #### [BarryCarlyon/twitch\_misc/blob/master/authentication/user\_access\_generator/php/index.php#L57](https://github.com/BarryCarlyon/twitch_misc/blob/master/authentication/user_access_generator/php/index.php#L57)
> 
> ```auto
> ));
> 
> // fetch the data
> $r = curl_exec($ch);
> // get the information about the result
> $i = curl_getinfo($ch);
> // close the request
> curl_close($ch);
> 
> if ($i['http_code'] == 200) {
> $token = json_decode($r);
> 
> // always a good idea to check the JSON parsed correctly
> if (json_last_error() == JSON_ERROR_NONE) {
> // looks good
> $_SESSION['token'] = $token;
> // file_put_contents( __DIR__. '/auth.json', $r, JSON_PRETTY_PRINT);
> 
> // login is complete
> // now we'll redirect home for the "main" viewer
> // so we can remove the ?code= from the URL
> 
> ```
> 
> Token is in `$token->access_token`
> 
> Also as shown elsewhere in my example I linked to

I already told you

And linked you example code

---

<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:** [January 26, 2021, 6:01pm UTC](https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-isnt-working/29665/23 "2021-01-26T18:01:10Z")

</div>

Closed on January 26, 2021, 6:01pm UTC

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

[Previous page](https://staging-discuss.dev.twitch.com/t/oauth-authorization-code-flow-isnt-working/29665.md?page=1)
