Can't create Access Token with code

Hi

I try to get an authorization_code with https://api.twitch.tv/kraken/oauth2/token with correct params but it return JSON code with status 404, it is normal ? I have try with /helix and /api but issue is same…

People know a solution with my issue ?

Are you doing a POST request as documented in step 3 of https://dev.twitch.tv/docs/authentication#oauth-authorization-code-flow-user-access-tokens?

1 Like

Yes, i have already make the same request before but now i have always 404 response code…

I try with some system but currently the result is same, 404 response code :confused:

Any people can confirm i can get access_token with curl in php ? :thinking:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.twitch.tv/kraken/oauth2/token');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
    'client_id' => $CLID,
    'client_secret' => $SECRET,
    'grant_type' => 'authorization_code',
    'redirect_uri' => $REDIRECT_URI,
    'code' => $_GET['code']
]));
$output = curl_exec($ch);
curl_close($ch);

$oauth = json_decode($output, true);
// $oauth['access_token'] is user's oauth token

is what works for me

1 Like

It’s curious i have no value in oauth :thinking: I don’t understand what is your php version ?

7.0

1 Like

Curious i’m with php 7.0.26 I have no result… Do you have an alternative code with php ?

On execution, the value $oauth = null if i print or var_dump it

Solution find ! Thank you for your help :smiley: I’m just too tired I think xP I have forget to define the right redirect_uri x)

1 Like

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