Authorizing fails with unsupported_response_type

I am following the Log In with Twitch guide and have run into a problem. When I redirect my user to the oauth2/authorize endpoint, they get directed back to my endpoint with ?error=unsupported_response_type&error_description=Response+type+is+not+supported tacked on.

I have tried setting my response_type parameter to code like the guide says as well as authorization_code but both have the same problem.

This may be a simple error but I am not seeing what is going wrong.
The code that accomplishes this is as follows, I am using guzzle for turning the authorize code into the one I can use if that matters:

<?php
require_once 'vendor/autoload.php';

session_start();

if (!isset($_GET['code'])) { //no auth
    header('Location: https://api.twitch.tv/kraken/oauth2/authorize'.
        '?client_id=<insert>'.
        '&redirect_uri=<this file>'.
        '&response_type=code'.
        'scope=channel_read');
} else { //maybe auth
    $client = new GuzzleHttp\Client();
    $req=$client->request('POST','https://api.twitch.tv/kraken/oauth2/token'.
        '?client_id=<insert>'.
        '&client_secret=<insert>'.
        '&code='.$_GET['code'].
        '&grant_type=authorization_code'.
        '&redirect_uri=<this file>');
    $res = json_decode($req->getBody());
    $_SESSION['twitch_auth'] = $res['access_token'];
    $redirect_url = "<fancy page>";
    header('Location: '.filter_var($redirect_url,FILTER_SANITIZE_URL));
}

Seems like you are missing a & here.

1 Like

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