Skip to content

Instantly share code, notes, and snippets.

@stevesohcot
Created October 10, 2021 19:56
Show Gist options
  • Select an option

  • Save stevesohcot/f783ca0b72237e8ece1ddde4ee134e8c to your computer and use it in GitHub Desktop.

Select an option

Save stevesohcot/f783ca0b72237e8ece1ddde4ee134e8c to your computer and use it in GitHub Desktop.
PHP Ring Central 3 Legged Auth Login - 2 of 2
<?php
require('vendor/autoload.php');
use RingCentral\SDK\Http\HttpException;
use RingCentral\SDK\Http\ApiResponse;
use RingCentral\SDK\SDK;
$rcsdk = new SDK(constant('RINGCENTRAL_CLIENT_ID'), constant('RINGCENTRAL_CLIENT_SECRET'), constant('RINGCENTRAL_SERVER_URL'));
$platform = $rcsdk->platform();
if (isset($_REQUEST['oauth2callback'])){
if (!isset($_GET['code'])) {
return;
}
$qs = $platform->parseAuthRedirectUrl($_SERVER['QUERY_STRING']);
$qs["redirectUri"] = constant('RINGCENTRAL_REDIRECT_URL');
$platform->login($qs);
$_SESSION['ringCentralSessionAccessToken'] = $platform->auth()->data();
header("Location: " . constant('RINGCENTRAL_REDIRECT_URL_INTERNAL'));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment