Facebook login error

  • Hi guys,
    I was looking for the facebook integration


    But i have an error

    “error”: {
    “message”: “Invalid redirect_uri: N\u00e3o \u00e9 poss\u00edvel carregar a URL”,
    “type”: “OAuthException”,
    “code”: 191,
    “fbtrace_id”: “B9Xhvdff”
    I chose the option website

    0_1468710850441_2016-07-16 (3).png

    0_1468710993004_2016-07-16 (2).png

    var app = angular.module('myApp', ['onsen.directives']);
    app.controller("ListCtrl", function(){
        this.num = friendsList.length;
        this.friends = friendsList;
    app.controller("HomeCtrl", ["$http", function($http){
        ConnectToFB = function(){
            var client_id = 'xxxxxxxx'; //YOUR App ID or API Key
                  var client_secret = 'xxxxxxxxxxx'; //// YOUR App Secret
            var redirect_uri = 'https://www.facebook.com/connect/login_success.html';  //// YOUR CALLBACK URL
            var display = 'touch';
            var authorize_url = "https://graph.facebook.com/v2.0/oauth/authorize?";
            authorize_url += "client_id=" + client_id;
            authorize_url += "&redirect_uri=" + redirect_uri;
            authorize_url += "&display=" + display;
            authorize_url += "&scope=publish_stream,offline_access";
             var ref = window.open(authorize_url, '_blank', 'location=yes');
            ref.addEventListener('loadstart', function(event)
                var loc = event.url;
                if(loc.indexOf(redirect_uri + "?") >= 0)
                    var result = loc.split("#")[0];
                    var accessToken = result.split("&")[0].split("=")[1];
                    var url = 'https://graph.facebook.com/v2.0/oauth/access_token?';
                        url += 'client_id=' + client_id;
                        url += '&client_secret=' + client_secret;
                        url += '&code=' + accessToken;
                        url += '&redirect_uri=' + redirect_uri;
                        accessToken = data.split("&")[0].split("=")[1];
                        url = "https://graph.facebook.com/v2.0/me/taggable_friends?access_token=" + accessToken;
                            this.friendsList = data.data;

  • @Leonardo-Augusto said:


    Googling the error code shows this:

    In FB App you have to assign an IP Site/ App Domain.

    Facebook matches this url with the url of the request where it came from.
    You can not assign localhost or
    You have to enter the IP address your server. Also if it is rails then call the site with your-ip:3000 instead of localhost:3000; I use
    Enter the same IP address in IP of the site and APP Domain in your FB APP Settings.

    Edit: Maybe a better answer: http://stackoverflow.com/questions/4691782/facebook-api-error-191

Log in to reply