AMPEDUPDESIGNS

CONSULTING CONCEPTS PERSONAL

Getting Intermittent Facebook API Error Code: 191

December 14th, 2012

Did you integrate Facebook Login Authentication in your website and you intermittently get a report from users of a "An error occurred. Please try again." message from Facebook? It's a great descriptive message unless the user is already logged into FB. Then they give you additional information like this:

API Error Code: 191

API Error Description: The specified URL is not owned by the application

Error Message: Invalid redirect_url: Given URL is not allowed by the Application configuration.

How to solve this:

1. Make sure your site URL specified in the app settings in Facebook match the one you are using in the redirect_uri. Don't use specific pages in the URL, just the domain like:

redirect_uri: http://www.yoursite.com/somepage.php
site url: http://www.yoursite.com

2. All above looks fine and it works for you, but you seem to be getting the problem intermittently? I found this to be the problem: Some users were going to http://yoursite.com instead of http://www.yoursite.com. Facebook was rejecting all requests coming from a non-www domain for my site.

There are various articles on the web for how to configure your server to redirect non-www urls to www urls. It's also always good practice to make your site search-engine friendly. Hope that helps.