5

Added domain in App Domains, Valid OAuth redirect URIs also added.. but, Getting error message like this I have done my best... Anybody help me... it was quite irritating, I'm loosing my patience and getting panic. I really don't know, what is my big mistake in this. See this following images to know more about my problem

Image 1

Image 2

Donald Duck
  • 8,409
  • 22
  • 75
  • 99

2 Answers2

24

We have 3 ways to fix it

1) Turn Off

Use Strict Mode for Redirect URIs

in Facebook Login-> Settings

2)

$accessToken = $helper->getAccessToken();

to

$accessToken = $helper->getAccessToken('https://example.com/your-CallBack-URI-page.php');

3) This is fine for development purpose when you don't want to waste time, for production use

session_start();
require_once __DIR__ . '/vendor/autoload.php';

$fb = new Facebook\Facebook([
  'app_id' => 'appid',
  'app_secret' => 'app secret',
  'default_graph_version' => 'v2.6 ', 
  "persistent_data_handler"=>"session"
  ]);
$helper = $fb->getRedirectLoginHelper();
$permissions = ['email']; // optional

$loginUrl = $helper->getLoginUrl('domain.com/php-graph-sdk-5.x/login-callback.php/', $permissions);
$_SESSION['FBRLH_state']=$_GET['state'];
try {
  $accessToken = $helper->getAccessToken('domian.com/php-graph-sdk-5.x/login-callback.php/');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  // When Graph returns an error
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  // When validation fails or other local issues
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
Omkar Frozen
  • 572
  • 6
  • 16
  • Thanks a lot this was exactly what my problem was :) Its funny because I've not seen this mentioned on any other site – mic Feb 26 '18 at 18:53
  • I had to spend some days fixing this. Glad it worked for you. – Omkar Frozen Feb 27 '18 at 11:54
  • great solution..but why this is happening? actually it returns the current session only, isn't it? @OmkarFrozen – Janen R Mar 02 '18 at 15:23
  • 1
    For me adding the URL to the getAccessToken function did the trick – mewiki Mar 17 '18 at 20:45
  • Thanks you saved my day . – ashutosh Mar 19 '18 at 10:15
  • Lifesaver, trying to figure this one out for days why my Facebook login implementations on all my sites stopped working suddenly – Aditya Mittal May 08 '18 at 12:05
  • For API version v3.1 and greater: `Use Strict Mode for Redirect URIs ` is now on by default and it's not possible to "TURN OFF" – Sgnl Aug 08 '18 at 20:31
  • thanks. adding redirect url worked. second solution above. – Arnold Feb 14 '20 at 16:03
  • This is great for me. I'm using AWS cloudfront . when facebook sing in call back. always show error msg ( Graph returned an error: Can't Load URL: The domain of this URL isn't included in the app's domains ) I don't why, untill I add Your Code. It's Working! Thank you very much. – user1859327 Dec 14 '20 at 03:14
4

From march the strict mode will be forced as enable. If you have any query parameters to your redirect url they should be included in the state parameter.

For details check my answer to a similar post.

chess4ever
  • 134
  • 11