} catch (ServiceException $se) { switch ($se->getErrorCode()) { case 400: // invalid_grant. Invalid Refresh token. // invalid_grant. Invalid Refresh token. case 401: // UnAuthorized Access. Invalid access token. unset($_SESSION['client_token']); if (DEBUG) { Debug::init(); Debug::write("Removed cached client token. Errocode=" . $se->getErrorCode() . "\n"); Debug::end(); } break; } return_json_error($se->getErrorCode(), $se->getErrorResponse()); } catch (Exception $e) { $error = $e->getMessage(); // some operations in the codekit do not throw ServiceException if (stripos($error, 'UnAuthorized Request') !== false) { unset($_SESSION['client_token']); if (DEBUG) { Debug::init(); Debug::write("token removed.\n"); Debug::end(); } return_json_error(401, "UnAuthorized Request. Try again to obtain a new access token."); } else { return_json_error(400, $error); } }
require_once "service_provider/Html5_ServiceProvider_Base_Att.php"; } $html5_serviceprovider_base = new Html5_ServiceProvider_Base_Att($config); if (isset($_GET['scope'])) { $scope = $_GET['scope']; if (DEBUG) { Debug::init(); $a = $_SESSION['consent_refresh_tokens'][$scope]; Debug::write("Revoke Old Refresh token: {$a}.\n"); Debug::end(); } if (isset($_SESSION['consent_tokens'][$scope])) { $html5_serviceprovider_base->revokeConsentToken($scope); //unset($_SESSION['consent_tokens'][$scope]); } } else { if (DEBUG) { Debug::init(); $a = $_SESSION['consent_refresh_tokens']['MIM']; Debug::write("Revoke Old Refresh token: {$a}.\n"); Debug::end(); } $html5_serviceprovider_base->revokeConsentToken('MIM'); $html5_serviceprovider_base->revokeConsentToken('IMMN'); } echo "{\"authorized\": false }"; } catch (ServiceException $se) { return_json_error($se->getErrorCode(), $se->getErrorResponse()); } catch (Exception $e) { return_json_error(400, $e->getMessage()); }