Where do i find my extension id?

Hello :slight_smile:

i was looking for the extension id but i was not able to find them in the console.

Greetings Andy

yeah i want to call Reference | Twitch Developers and there is an extension id as get parameter and a client id so i was a bit confused.

The terms can be used interchangebly

ok :slight_smile: but i get the error “Client ID and OAuth token do not match” but with exact the same clientID the token was created.

You did use the Client ID and Extension Client Secret to generate an App Access Token to all the API with

Specifying the ClientID in the header? And The ExtensionID in the params (which is the clientID)

Yes i use the client-id from the box and the client-secret which i have generated. I also get with the exact same data the token.

So what does your code look like to make the call with

function create_app_access_token() {
    // Twitch-Anmeldedaten
    $clientId = 'XXX';
    $clientSecret = 'XXX';

    $tokenURL = 'https://id.twitch.tv/oauth2/token';
    $params = array(
        'client_id' => $clientId,
        'client_secret' => $clientSecret,
        'grant_type' => 'client_credentials'
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $tokenURL);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($ch);
    curl_close($ch);

    $responseData = json_decode($response, true);
    if (isset($responseData['access_token'])) {
        $accessToken = $responseData['access_token'];
        return $accessToken;
    } else {
        return false;
    }
}

function get_extension_stats() {
    $accessToken = create_app_access_token();
    $extensionID = 'XXX';

    $apiURL = 'https://api.twitch.tv/helix/extensions/transactions';
    $params = array(
        'extension_id' => $extensionID
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $apiURL . '?' . http_build_query($params));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Client-ID: XXX',
        'Authorization: Bearer ' . $accessToken,
    ));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);

    // Antwort verarbeiten
    $responseData = json_decode($response, true);
    if (isset($responseData['data'])) {
        $transactions = $responseData['data'];
        var_dump($transactions);
    } else {
        var_dump($responseData);
    }
}

So you are passing the clientID as XXX?

Shouldn’t it be

    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Client-ID: ' . $extensionID,
        'Authorization: Bearer ' . $accessToken,
    ));

Also note that clientID’s are essentially public so you don’t need to worry about redacting them

And $clientId and $extensionID are the same value?

Its working…i was generating a new secret.

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