Friday, July 29, 2016

Error messages when trying to use the Facebook API

Leave a Comment

I am getting an error message when attempting to use the Facebook API.

When I have Client OAuth Login enabled, Web OAuth Login enabled and a valid Oauth redirect URI set to http://localhost:8000/ the error I get is this when trying to log into Facebook with the correct App ID:

URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings. Make sure Client and Web OAuth Login are on and add all your app domains as Valid OAuth Redirect URIs.

Is there a particular setting or thing I have to put in code to get this to work correctly?

This is the code I've got:

    $(window).load(function() {         if (window.cordova.platformId == "browser") {             facebookConnectPlugin.browserInit(MYAPPIDHERE);         }     }); 

And this:

            facebookConnectPlugin.login(["user_likes"],                     function(response) {                         likes();                     },                     function(response) {                         likes();                     });         } 

EDIT:

Added pictures of what is in the Facebook App, as well as the URL I am navigating from.

enter image description here

enter image description here

2 Answers

Answers 1

The Javascript API wont work on PhoneGap for the login. Use this cordova plugin instead.

https://github.com/Wizcorp/phonegap-facebook-plugin

Answers 2

It is impossible for Facebook to redirect to a local URL. What will happen is that you redirect a user to Facebook, they login, Facebook validates this and sends them back to you. Facebook sends them to the URL you provide. The URL http://localhost:8000 is a shorthand for: connect to port 8000 on your own machine. At the point where Facebook does the redirect, localhost refers back to Facebook, not you anymore. Apparently, Facebook has blacklisted that stuff - probably for security reasons.

What you need is a public URL that Facebook can redirect to. Maybe this helps?

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment