Can't create Access Token with code

$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