123 private function makeUrl($redirectUrl, array $scope, array $params = [], $separator =
'&')
125 $state = $this->persistentDataHandler->get(
'state') ?: $this->pseudoRandomStringGenerator->getPseudoRandomString(static::CSRF_LENGTH);
126 $this->persistentDataHandler->set(
'state', $state);
128 return $this->oAuth2Client->getAuthorizationUrl($redirectUrl, $state, $scope, $params, $separator);
140 public function getLoginUrl($redirectUrl, array $scope = [], $separator =
'&')
142 return $this->makeUrl($redirectUrl, $scope, [], $separator);
162 if ($accessToken->isAppAccessToken()) {
168 'access_token' => $accessToken->getValue(),
171 return 'https://www.facebook.com/logout.php?' . http_build_query($params,
null, $separator);
185 $params = [
'auth_type' =>
'rerequest'];
187 return $this->makeUrl($redirectUrl, $scope, $params, $separator);
201 $params = [
'auth_type' =>
'reauthenticate'];
203 return $this->makeUrl($redirectUrl, $scope, $params, $separator);
217 if (!$code = $this->
getCode()) {
224 $redirectUrl = $redirectUrl ?: $this->urlDetectionHandler->getCurrentUrl();
228 return $this->oAuth2Client->getAccessTokenFromCode($code, $redirectUrl);
240 throw new FacebookSDKException(
'Cross-site request forgery validation failed. Required GET param "state" missing.');
242 $savedState = $this->persistentDataHandler->get(
'state');
244 throw new FacebookSDKException(
'Cross-site request forgery validation failed. Required param "state" missing from persistent data.');
247 if (\hash_equals($savedState, $state)) {
251 throw new FacebookSDKException(
'Cross-site request forgery validation failed. The "state" param from the URL and session do not match.');
257 private function resetCsrf()
259 $this->persistentDataHandler->set(
'state',
null);
269 return $this->getInput(
'code');
279 return $this->getInput(
'state');
289 return $this->getInput(
'error_code');
299 return $this->getInput(
'error');
309 return $this->getInput(
'error_reason');
319 return $this->getInput(
'error_description');
329 private function getInput($key)
331 return isset(
$_GET[$key]) ?
$_GET[$key] :
null;