switch ($provider) {
// Internal authentication is several steps
// Get temporary token using Internal application credentials
// Then reload the page catching an oauth_verifier parameter from Internal
// Get permament token using temporary token
// Then reload the page
case 'internal':
$internalService = $serviceFactory->createService('internal', $credentials, $storage, array());
if (!empty($_GET['code'])) {
// This was a callback request from google, get the token
$internalService->requestAccessToken($_GET['code']);
// Send a request with it
$result = json_decode($internalService->request('https://accounts.iiet.pl/appapi/v1/students/me'), true);
$oauth_profile = array(
'id' => $result['user_id'],
);
} else {
if (isset($_GET['remember'])) {
setcookie('remember', $_GET['remember'], time() + 3600, '/');
}
setcookie('redirect_to', $_SERVER['HTTP_REFERER'], time()+3600, '/');
$url = $internalService->getAuthorizationUri();
header('Location: ' . $url);
}
break;
default:
$message = $user->lang['OAUTH_UNKOWN_PROVIDER'];
meta_refresh(3, $phpbb_root_path);
trigger_error($message);
break;
}