4

I know that this question has been asked previously in this link Facebook OAuth "The domain of this URL isn't included in the app's domain" , but the solution is not working for me.

It’s showing the error like this: enter image description here

I have included my domain in the app’s domain of facebook api as well, The redirect url format that I am passing goes like this: https://example.com/clients/authorization/facebook/a1njk2nkll55343nlk4/page

Here the random characters after facebook/ is the id of the client which is dynamic.

Moreover, I am having the same problem while logging through facebook as well.

Thank You.

Prashant
  • 1,375
  • 2
  • 14
  • 22

3 Answers3

4

This might be the problem due to the security update of Facebook API.

This is from Facebook developer dashboard!

"In March, we're making a security update to your app settings that will invalidate calls from URIs not listed in the Valid OAuth redirect URIs field"

So, for that Add your site's callback url in the Valid OAuth redirect URIs field

You need to add your oAuth Redirect URI properly in the Facebook Login->Settings: Valid OAuth Redirect URIs In Valid OAuth Redirect URIs, You can include the uri in this format: https://example.com/clients/authorization/facebook

And the redirect uri while authenticating can be as follow: https://example.com/clients/authorization/facebook&a1njk2nkll55343nlk4/page

Here "&" separates your required other parameters.

The same case applies for facebook Login. Add your full login redirect uri to the Valid OAuth Redirect URIs. Like this:

https://example.com/login/facebook/callback

Hope This helps.

Thanks.

KCP
  • 929
  • 9
  • 29
  • It worked. Thanks. But I want to pass another parameter (eg: client_id ) too which are dynamic with the callback url so that, I can track the id for which I am authorizing. Right now I am not getting the client_id that is mentioned in the callback url. Can you please explain this? – Prashant Mar 22 '18 at 15:02
  • If you are using PHP SDK then first of all update it as mentioned by @JorgeO below. And then, set the 'state' parameter for your client_id. where your url will be https://example.com/clients/authorization/facebook/page&state=id And then in Valid OAuth Redirect URI in facebook developer console include https://example.com/clients/authorization/facebook/page – KCP Mar 22 '18 at 15:12
  • Tweaking settings did not work for me, updating `facebook/graph-sdk` from 5.6.1 to 5.6.2 fixed the problem. – The Onin Mar 27 '18 at 03:40
  • Then you might have inserted full URL in the Redirect URI previously. – KCP Mar 27 '18 at 11:12
  • it doens't work for me. I have graph-sdk 5.6.2 and already set my callbackurl to Valid OAuth Redirect URI but adding parameter doesn't work – RaffyM Apr 15 '18 at 01:08
3

A dynamic URL Redirect is not supported by the current behavior.

This is due to a change to the handling of redirect URIs, announced in December 2017, and taking effect this month, Enabling strict mode is required in order to use OAuth redirects:

https://developers.facebook.com/blog/post/2017/12/18/strict-uri-matching/

Make sure to set App Domain in:

https://developers.facebook.com/apps/[your-app-ip]/settings/basic/

Also all you callback urls including the https:// Please see:

https://developers.facebook.com/apps/[your-app-ip]/fb-login/settings/

  • If you are using the PHP SDK, please ensure you have the latest version installed (v5.6.2).
JorgeO
  • 2,210
  • 5
  • 20
  • 22
0

I had issues with this. Noticed that after moving to https:// it still redirects to http:// after long hours of looking into fb sdk found that they had issues detecting if your site is secure.

So, on file

facebookd-v5.*-sdk/Url/FacebookUrlDetectionHandler.php update two functions. Updated versions:

protected function protocolWithActiveSsl($protocol)
{
    $protocol = strtolower((string)$protocol);

    return in_array($protocol, ['on', '1', 'https', 'ssl', 'https, https'], true);
}

and

protected function getHostName()
{
    ...

    // Don't append port number if a normal port.
    if (($scheme == 'http' && $port == '80') || ($scheme == 'https' && $port == '443') || ($scheme == 'https' && $port == '80')) {
        $appendPort = '';
    }

    return $host . $appendPort;
}
celsyum
  • 1
  • 1