Skip to content
Joe Foster edited this page Sep 30, 2022 · 4 revisions

USE AT OWN RISK

OK so you include the api you direct the user to login your script must then do the following set a state as a $_GET request i use login2 like so

$extra = array('state' => 'login2');

then request your token

$bob = $api->getAccessToken($api->baseurl[$api->region]['TOKEN_ENDPOINT'], 'client_credentials', $parameters);

this gets your token then set it and the type

$api->setAccessToken($bob['access_token']);
$api->setAccessTokenType(1);

then create your auth url and redirect like so

if (!isset($_GET['code']))
{
	$auth_url = $api->getAuthenticationUrl($api->baseurl[$api->region]['AUTHORIZATION_ENDPOINT'], $api->redirect_uri);
	echo '<script> location.replace("'.$auth_url.'"); </script>';
	exit();
}

$params = array('code' => $_GET['code'], 'auth_flow' => 'auth_code', 'grant_type' => 'authorization_code', 'redirect_uri' => $api->redirect_uri.$page);

$response = $api->getAccessToken($api->baseurl[$api->region]['TOKEN_ENDPOINT'], 'authorization_code', $params);
$api->setAccessToken($response['access_token']);

Clone this wiki locally