Redirecting to authentication dialog - "An error occurred. Please try again later"

PhpFacebookFacebook Graph-Api

Php Problem Overview


Why does it always happen to me?

This happens after my application verify for user user login and redirect user to the authentication page:

https://www.facebook.com/dialog/oauth?client_id=XXX&redirect_uri=http%3A%2F%2Fexample.com%2Fmyappname%2F&state=YYYYYY&scope=offline_access%2Cpublish_actions

But instead of showing the authorization page, Facebook shows an error page with > An error occurred. Please try again later.

Is there any configuration I have to do before try to authenticate my users?

All is done with PHP using the PHP-SDK classes.

Php Solutions


Solution 1 - Php

I have had the same problem as you.

From the Facebook Developers Apps page, make sure that the Sandbox Mode is disabled.

enter image description here

Solution 2 - Php

I had the same problem after changing the domain of my site. Altough I properly changed the request_uri parameter and updated my app settings with the new domain, the error kept showing up. Then I realized that the ID and the SECRET ID of my Facebook APP had automatically changed with no warning!! The whole thing started working again using the new ID.

Solution 3 - Php

This was happening to me also but all the api keys, secrets and stuff were correct. What I found is that my app was running in sandbox mode. Go to your app settings in https://developers.facebook.com/ click the advanced settings tab and check to see if your app is in sandbox mode. If it is disable it and try again. Let us know if it works.

Solution 4 - Php

I was getting this error because I was starting from http://mysite.com, but had specified http://WWW.mysite.com in my Facebook settings - the www mattered... I ended up solving by using .httpaccess to always kill the "www", and pointing FB to http://mysite.com

worst. subdomain. ever. :u)

Solution 5 - Php

When working with Dialogues, Facebook provide a 'show_error' attribute that defaults to no but can be set to true in a Development environment and is really helpful for debugging purposes.

> show_error - If this is set to true, the error code and error description will be displayed in the event of an error.

Instructions of it's use can be found in the Facebook Docs.

I'd been debugging "An Error occurred. Please try later." dialogue before i found this attribute in the docs. Once i started using it, i could see the following message too:

> API Error Code: 191 > > API Error Description: The specified URL is not owned by the application > > Error Message: redirect_uri is not owned by the application.

Solution 6 - Php

I had the same problem; it turned out FB requires a string appID and not an int...

//DOESNT WORK:
$facebook = new Facebook(array(
  'appId'  => 147XXXXXXXXXXX,
  'secret' => 'XXXXXXXXXXXXXX',
));

// WORKS:
$facebook = new Facebook(array(
  'appId'  => '147XXXXXXXXXXX',
  'secret' => 'XXXXXXXXXXXXXX',
));

Solution 7 - Php

For me this happened because the "test user" I created was part of a separate app. I created a test user for THIS app, and it started working fine.

Stupid on my part I know, but this could save someone else some trouble.

Solution 8 - Php

Make sure your app is configured to use the appropriate URL & domain of your site. That may be it.

Solution 9 - Php

According to OAUTH Dialog documentation:

redirect_uri: The URL to redirect to after the user clicks a button in the dialog. The URL you specify must be a URL of with the same Base Domain as specified in your app's settings, a Canvas URL of the form https://apps.facebook.com/YOUR_APP_NAMESPACE ...

I am constructing oauth links dynamically to ask a user for additional permissions if needed and I realized, that even if you are redirecting to https://apps.facebook.com/YOUR_APP_NAMESPACE you have to have the App Domain and Website settings set in your application administration. I set domain to facebook.com and Website to facebooks root url.

Now my oauth dialog link works fine - even in sandbox mode.

Solution 10 - Php

I had this exact problem on a Page Tab app and for the life of me couldn't work out what the problem was. It worked on my test page but as soon as I made it live it wouldn't work. I found in the end that I fixed the problem by putting the actual URL to the Page Tab (i.e. http://www.facebook.com/<"page_name">/app_<"app_id">) into "Site URL" under "Website". This doesn't make any sense. But it worked :-)

Solution 11 - Php

Solution for me is to set option 'Authenticated Referrals' to enabled. Its realy fixed after that.

Fix permissions error

Solution 12 - Php

The issue resolved after I updated the 'appID' and 'secret' and then pushed the change back to heroku (i.e. - 'git push heroku master')

The key is not to forget to push the changes back to heroku master. Very easy to overlook if you're use to testing on localhost.

Hope this helps.

Solution 13 - Php

For me the problem was that the Facebook users I was using to test the app did not have its email address confirmed by Facebook.

My client had set up 2 fake accounts on Facebook and told me that they were not working. But he forgot to confirm the email addresses of those accounts (the emails Facebook sent went to his spam folder and he didn't notice).

Took me hours to find this, so I hope it helps somebody.

Cheers!

Solution 14 - Php

Also had a problem with wrong redirect link: I had a link starting with "https://apps.facebook.com?myapplication";.... but after authorization the redirection would bring me to "apps.facebook.com/Myapplication" and consequently I would get a message described above:"Error occured. Try back later." since "apps.facebook.com"... means "http://apps.facebook.com/Myapp" and not "HTTPS://apps.facebook.com/,..."

The solution: went to my application settings in facebook developers section. Clicked 'Edit'. In the left-side Menu selected "Permissions" (by default the Menu is set to Basic) and in the newly opened set of setting changed my "Auth Token Parameter" from "Query string" to "URL Fragment".

It worked! After authorization is finished the users are taken to "https://apps.facebook.com/myapp..."

Solution 15 - Php

Another possible mistake, if you directly copied the code from Facebook SDK example then you may get the same error despite of having everything correct. http://developers.facebook.com/docs/reference/php/

This is because in their example they have used backquotes instead of single quotes for the key of the array. The correct code is as follows.

require_once("facebook.php");

$config = array();
$config['appId'] = 'YOUR_APP_ID';
$config['secret'] = 'YOUR_APP_SECRET';
$config['fileUpload'] = false; // optional

$facebook = new Facebook($config);

Solution 16 - Php

If your all code is working properly then to remove such type of error go to Facebook Developers Apps and disable sandbox mode.

Solution 17 - Php

I just encountered this problem myself. I'm developing an app internally, so my host is 'localhost'. It wasn't obvious how to set 'localhost' up in the app configuration. If you want to develop locally, set up your app by following these steps:

  1. Go to the place where you manage your Facebook app. Specifically, you want to be in "Basic" under the "Settings" menu.
  2. Add 'localhost' to "App Domain".
  3. Under "Select how your app integrates with Facebook", select "Website", and enter "http://localhost/";.

Save and wait a couple of minutes for the information to propagate, although it worked right away for me.

Solution 18 - Php

I had put the restriction on the app that only United States residence could use the app. I was working from Canada at the time this error message appeared. After removing the restriction everything worked.

Solution 19 - Php

Came here with a similar problem and, yes, my Sandbox was enabled. I disabled it and, voila, the login problem went away. I must warn that this problem does not affect developers and website administrators as Facebook allows those users to see the app. For this reason, I couldn't even believe that users complained about not being able to login, as I was able to login with no problems at all.

Solution 20 - Php

I had the same problem, and fix it by adding param &display=touch to url

try, it may helps

Solution 21 - Php

Answer for 2015

Sandbox mode is gone.

Proceed to My Apps -> Your App -> Status & Review and change the slider to yes for:

Do you want to make this app and all its live features available to the general public?

enter image description here

Solution 22 - Php

If you're the app developer, you may see a more specific error message, but generally that message means one of two things:

  1. Your server returned a HTTP error code (usually 5xx)
  2. You tried to send the user, after login, to a URL not allowed by your app configuration (though as an Admin of the app, you should see a more specific error message and Facebook error code in this case)

Solution 23 - Php

I had this error because I was using redirect_url as a parameter instead of redirect_uri.

The Server-Side Authentication doc page says to use redirect_url:

https://www.facebook.com/dialog/oauth?
    client_id=YOUR_APP_ID
   &redirect_url=YOUR_REDIRECT_URI
   &scope=COMMA_SEPARATED_LIST_OF_PERMISSION_NAMES
   &state=SOME_ARBITRARY_BUT_UNIQUE_STRING

But this is incorrect. The OAuth Dialog doc says to use redirect_uri instead, which works, so I'm assuming that you can only use one and not the other:

https://www.facebook.com/dialog/oauth/?
    client_id=YOUR_APP_ID
    &redirect_uri=YOUR_REDIRECT_URL
    &state=YOUR_STATE_VALUE
    &scope=COMMA_SEPARATED_LIST_OF_PERMISSION_NAMES

Solution 24 - Php

You need to specify http:// in your REDIRECT URI.

Solution 25 - Php

I had tried all the answers mentioned here. But it didn't work. I had to delete and create again. I am guessing it was due to new the "Authenticated Referral". If you have added Open Graph objects which are not approved, it might give you an error.

Solution 26 - Php

I had the same problem and the root cause was different:

I was logged in as a Test User of a different application. Therefore I wasn't able to authorize an app that's not the one where the Test User was created for.

When I logged out and logged in as a regular user or a Test User for the app I tried to authorize, everything was OK.

Solution 27 - Php

In my case, there was an age issue with the account being used with the app.

If the FB app has alcoholic content then FB users who are younger than about 21 will throw an error when trying to authorize with it.

Solution 28 - Php

For me the issue was that the url of the app didn't completely match the url I was running it on (i.e different directories, same domain)

Solution 29 - Php

There is no possibility to solve this type of error. So Its better to use your custom dialog same like shown in facebook and post message again & again without login. Even though you remove your app from facebook, you can ask for login and post message successfully.

Solution 30 - Php

The reason in my case was completely different. I was trying to open a Feed dialog automatically after page load. And 9 times of 10 it displayed this error. First, I added show_error: true parameter as suggested by @Peter Roome, but it didn't help, displaying 104: Invalid signature, not descriptive at all.

Then I figured out the reason. The code was in $(document).ready jQuery function. And it seems that some facebook stuff had not yet been loaded at the point the code was to be executed. I moved the code to $(window).load block (which is executed after all page content is loaded), and the problem has been solved.

Solution 31 - Php

I know u may got the answer but this is for those who are still going down the thread for getting the solution.

U can try all the above solutions but just remember that delete the Previous app from the device or simulator before checking another solution.

I tried all solutions but getting no response as i was not deleting the previous app, only cleaning the build does not satisfy the condition.Hope it helps someone. :)

Solution 32 - Php

Settings > advanced > security > valid oauth redirect URI

enter image description here

Solution 33 - Php

I faced the same problem and reason was that my app was not live and publicly available.

> I added my email id in contact email under setting tabs and make my app live(which previously was disabled to make live).

After making my app live its showing sharing dialogue with proper image, title and description with my app name in bottom.

Solution 34 - Php

Check your appid and make sure you have updated your Site URL Mobile Site URL in https://developers.facebook.com/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionWanderson SilvaView Question on Stackoverflow
Solution 1 - PhpdxitView Answer on Stackoverflow
Solution 2 - PhpalbertView Answer on Stackoverflow
Solution 3 - PhpJuankView Answer on Stackoverflow
Solution 4 - Phpcase2000View Answer on Stackoverflow
Solution 5 - PhpPeteView Answer on Stackoverflow
Solution 6 - PhpJaredBroadView Answer on Stackoverflow
Solution 7 - PhpJames PeltonView Answer on Stackoverflow
Solution 8 - PhpSBerg413View Answer on Stackoverflow
Solution 9 - PhpTomas MolnarView Answer on Stackoverflow
Solution 10 - PhpOwen DaveyView Answer on Stackoverflow
Solution 11 - PhpFelikZView Answer on Stackoverflow
Solution 12 - PhpedwinjueView Answer on Stackoverflow
Solution 13 - PhpBitcoin Cash - ADA enthusiastView Answer on Stackoverflow
Solution 14 - PhpanneView Answer on Stackoverflow
Solution 15 - PhpSanket SahuView Answer on Stackoverflow
Solution 16 - PhpSurajView Answer on Stackoverflow
Solution 17 - PhpMe TooView Answer on Stackoverflow
Solution 18 - PhpChrisView Answer on Stackoverflow
Solution 19 - PhpLizardKGView Answer on Stackoverflow
Solution 20 - PhpSergey NikolaevView Answer on Stackoverflow
Solution 21 - PhpAbramView Answer on Stackoverflow
Solution 22 - PhpIgyView Answer on Stackoverflow
Solution 23 - Phpuser456814View Answer on Stackoverflow
Solution 24 - PhpChris KirbyView Answer on Stackoverflow
Solution 25 - PhpRahulView Answer on Stackoverflow
Solution 26 - PhpyonixView Answer on Stackoverflow
Solution 27 - PhpChrisView Answer on Stackoverflow
Solution 28 - PhpAliView Answer on Stackoverflow
Solution 29 - PhpHetal ModiView Answer on Stackoverflow
Solution 30 - PhpDennis GolomazovView Answer on Stackoverflow
Solution 31 - PhpmAcView Answer on Stackoverflow
Solution 32 - PhpPablo S G PachecoView Answer on Stackoverflow
Solution 33 - PhpRN KushwahaView Answer on Stackoverflow
Solution 34 - PhpshaikView Answer on Stackoverflow