include 'vendor/autoload.php';
$client_id = "";
$client_secret = "";
$scopes = "";
$callback = "" //callback url
$auth_url = "https://marketplace.gohighlevel.com"; // use: https://marketplace.leadconnectorhq.com for whitelabel
$url = "$auth_url/oauth/chooselocation?response_type=code&redirect_uri=$callback&client_id=$client_id&scope=$scopes";
echo header("Location: $url");
$ghl_access = \MusheAbdulHakim\GoHighLevel\GoHighLevel::getAccessToken('https://services.leadconnectorhq.com/oauth/token', 'application/x-www-form-urlencoded', [
'client_id' => $client_id,
'client_secret' => $client_secret,
'grant_type' => 'authorization_code',
'code' => $code // code obtained from the authorization,
'redirect_uri' => $callback,
]);
$client->oAuth()->AcessFromAgency($companyId, $locationId)
$client = \MusheAbdulHakim\GoHighLevel\GoHighLevel::client($key, '2021-07-28');
$location = $client->oAuth()->location($appId, $companyId)
or
$location = $client->oAuth()->appLocation($appId, $companyId);