Once a user has given approval from the /authorize endpoint, use this endpoint to receive an access_token.

Refreshing tokens

Below is a sample code for refreshing tokens.

<?php

  $client = new GuzzleHttp\Client();

  try {

    //if using Guzzle 6+ change "body" to "form_params"
    $response = $client->post('https://streamlabs.com/api/v2.0/token', [
      'body' => [
        'grant_type'    => 'authorization_code',
        'client_id'     => 'YOUR_CLIENT_ID',
        'client_secret' => 'YOUR_CLIENT_SECRET',
        'redirect_uri'  => 'YOUR_CLIENT_REDIRECT_URI',
        'code'          => $_GET['code']
      ]
    ]);

    $result = $response->json();

  } catch (Exception $e) {

    //failed
    $result = $e->getResponse()->json();

  }

?>
<?php

  $client = new GuzzleHttp\Client();

  try {

    //if using Guzzle 6+ change "body" to "form_params"
    $response = $client->post('https://www.twitchalerts.com/api/v2.0/token', [
      'body' => [
        'grant_type'    => 'refresh_token',
        'client_id'     => 'YOUR_CLIENT_ID',
        'client_secret' => 'YOUR_CLIENT_SECRET',
        'redirect_uri'  => 'YOUR_CLIENT_REDIRECT_URI',
        'refresh_token' => 'REFRESH_TOKEN_HERE'
      ]
    ]);

    $result = $response->json();

  } catch (Exception $e) {

    //failed
    $result = $e->getResponse()->json();

  }

?>
Language