OAuth 2
The Streamlabs API uses OAuth 2 for authentication. OAuth 2 can be a little tricky to get started with, and to make it easier we suggest you use an existing SDK. Once you have authenticated a user, include an authorization parameter or header containing a valid access_token in every request.
Do Not Refresh Tokens
You don't need to refresh the token, because our token will never expire. Just FYI. if you are interested in refreshing the tokens, use following code as a reference.
<?php
//get the following from your database
$access_token = 'A4F3D';
$refresh_token = '1Z5G9';
$expires_in = 3600;
$created_at = 1438711601;
$client = new GuzzleHttp\Client();
//check if the access_token is expired
if ($created_at + $expires_in < now()) {
//the token is expired, get a new one
$response = $client->post('https://streamlabs.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
]
])->json();
//save this new data to your database
$access_token = $response['access_token'];
$refresh_token = $response['$refresh_token'];
$expires_in = $response['$expires_in'];
$created_at = now();
}
//proceed to make your API call
Updated almost 2 years ago
What’s Next
Now lets jump right into registering your application and make use of the Streamlabs API.