Tuesday, February 15, 2022

[FIXED] Facebook App Login Error

Issue

I've been looking everywhere for a solution to my problem, but to no avail so far.

I'm following steps to create a Facebook app from a Facebook Tutorial and I've run into a problem in the logging in process even though I seem to be doing everything correctly. When the app tries to login, I get the following error:

Given URL is not permitted by the application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

You would think that there's something wrong with my app configuration, but that doesn't seem to be the case. Here's a screenshot:

enter image description here

The canvas URL is correct and I've tested with or without the App Domains field filled out. Here is the php for the login:

<?php
    require 'server/fb-php-sdk/facebook.php';

    $app_id = '236534686497558';
    $app_secret = '***************************';
    $app_namespace = 'mytestsmash';
    $app_url = 'https://apps.facebook.com/' . $app_namespace . '/';
    $scope = 'email,publish_actions';

    // Init the Facebook SDK
    $facebook = new Facebook(array(
         'appId'  => $app_id,
         'secret' => $app_secret,
));

// Get the current user
$user = $facebook->getUser();

// If the user has not installed the app, redirect them to the Login Dialog
if (!$user) {
        $loginUrl = $facebook->getLoginUrl(array(
        'scope' => $scope,
        'redirect_uri' => $app_url,
        ));

        print('<script> top.location.href=\'' . $loginUrl . '\'</script>');
}
?>

I can't figure out what's going wrong here.


Solution

Realized the issue was the $app_url was httpS in the php... but the canvas page url in the settings was just http!



Answered By - dlofrodloh

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.