What is grant type

i need bearer access token.

and my php curl code.

    $client_id = 'my_id';
$client_secret = 'my_secret_pwd_id';
$grant_type = 'refresh_token';
$scope = '';
$URL = 'https://id.twitch.tv/oauth2/token';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
    'client_id' => $client_id,
    'client_secret' => $client_secret,
    //'grant_type' => $grant_type,
    //'scope' => $scope,
$output = curl_exec($ch);

$oauth = json_decode($output, true);

i don’t understand grant_type.

scope is optional.

Grant Type depends on the type of token you want

There are generally three kinds of Twitch token.

  • token and code involves a user and redirecting the user to the constructed URL
  • client_credentials lets you make a server to server token for endpoints that don’t require a user token

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