Facebook produces "An error occurred. Please try later" when handling oauth request

16,943

The error turned out to be caused by the redirect URI http://facebook.com/[..].

Usually, if unauthorized domain is used, Facebook produces an error that you have to add the domain to Facebook app settings, App Domain. In this case, it simply produces completely useless An error occurred. Please try later.

Share:
16,943
Gajus
Author by

Gajus

Marketing mind with a blend of Developer, Technical Director, Systems Architect and Project Manager background. Founder of http://anuary.com and http://applaudience.com.

Updated on June 13, 2022

Comments

  • Gajus
    Gajus almost 2 years

    This has been discused on SOF, though, I didn't find anyone having exactly the same problem. Furthermore, it's been more than 2 days now, so I figured to ask.

    1. App is running in a sandbox. Update: the same is happening in sandbox-less environment.
    2. Doesn't work regardless if I use admin, developer or tester account.
    3. Doesn't work regardless of whether the user has authorized the app already or not.

    Just before calling $fb->getLoginError(), the $fb instance dump (Facebook PHP-SDK) looks like the following:

    object(Facebook)#85 (7) {
      ["appId:protected"]=>
      string(15) "[removed for SOF display]"
      ["apiSecret:protected"]=>
      string(32) "[removed for SOF display]"
      ["user:protected"]=>
      int(0)
      ["signedRequest:protected"]=>
      NULL
      ["state:protected"]=>
      string(32) "[removed for SOF display]"
      ["accessToken:protected"]=>
      string(48) "[removed for SOF display]"
      ["fileUploadSupport:protected"]=>
      bool(false)
    }
    

    All the [removed for SOF display] information is present.

    The code itself:

    $login_url      = $fb->getLoginUrl(array('scope' => $config->facebook['scope'], 'redirect_uri' => $redirect_uri ));
    
    echo '
        <noscript>javascript must be enabled.</noscript>
        <script type="text/javascript">top.location.href = \'' . addslashes($login_url) . '\';</script>
    ';
    

    The URL generated by getLoginUrl() is the following:

    https://www.facebook.com/dialog/oauth?client_id=[removed for SOF display]&redirect_uri=[removed for SOF display]&scope=publish_stream%2C+email%2C+user_birthday%2C+user_interests%2C+user_likes
    

    The most annoying thing is that Facebook is producing error An error occurred. Please try later without any additional information. I've even tried to set $login_url to something stupid like http://google.com/ which didn't produce expected error. Just the same An error occurred. Please try later.

    I've been developing apps for quite a while and this is the first time I am having an issue as such.