0

I am developing a Facebook canvas app.

Trying to login and authorize my app is working fine.

But this scenario doesn't work.

  1. I open my application canvas https://apps.facebook.com/{appID}
  2. Click on Continue as button.
  3. Popup will show and I click on Continue As... to authorize.
  4. Every thing looks fine and it's redirecting to main.php
  5. I go to app settings and remove my app. Update: Also logoff all facebook; same result!
  6. Here I am expecting main.php to alert me that the user removed app (deauthorized) then logoff
  7. Nothing happen and user still in the page

Here is my code:

// Load the SDK asynchronously
(function (d, s, id) {
    var js,
    fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id))
        return;
    js = d.createElement(s);
    js.id = id;
    js.src = "//connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
}
    (document, 'script', 'facebook-jssdk'));

window.fbAsyncInit = function () {
    FB.init({
        appId: '{APPID}',
        cookie: true, // enable cookies to allow the server to access
        // the session
        xfbml: true, // parse social plugins on this page
        version: 'v2.10', // use graph api version 2.8
        status: true,
        oAuth: true

    });

    //start coding
    // here trying all types of events subscribe to check if something
    // missing or if I am subscribing the wrong event
    FB.Event.subscribe('auth.authResponseChange', function (response) {
        alert("authResponseChange=" + response);
    });

    FB.Event.subscribe('auth.login', function (response) {
        alert("login=" + response);
    });

    FB.Event.subscribe('auth.statusChange', function (response) {
        alert("statusChange=" + response);
    });

    FB.getLoginStatus(function (response) {
        alert("getLoginStatus=" + response);
    });

};

function ReadPHPresponse(data, cmd) {
    //TODO
}

// end coding

App environments:

  1. App in development mode
  2. Its running on localhost WAMP
  3. Tried everything I could to disable caching: WAMP, FB Calls, stats:true
  4. In App setting I select the canvas URL to https://localhost/ and app domain to localhost
  5. In Facebook Login Products setting also I checked Valid OAuth redirect URIs to https://localhost/
  6. FB API version 2.10

Still not firing and users not logged off when they remove my app. If I refresh main.php its working and users get logged off.

I saw the following similar questions/answer but none of them solve my issue.

why facebook FB.Event.subscribe is not working?

how to detect log out from fb using JS SDK without refreshing the page

FB JS-SDK cannot detect user logging out of FB directly

How to detect user logging out of Facebook after logging into my app?

I wonder whats wrong.

Thank you

Update: the event is fired but after waiting like an hour; so most likely its some caching issue! Can't be sure.

Update2:

Trying to figure out whats wrong! I had tried the following:

  1. Downgrade jQuery from version 3 to version 2
  2. Load my app from Live Server and not localhost
  3. Check app settings
  4. Check console.log for everything; but no error is returned! with All Levels enabled; I am getting only [Violation] 'message' handler took 2450ms
  5. Checked Facebook Platform and it is Healthy
  6. Loaded Facebook SDK into <head> (sdk.js)
  7. Tried different browsers Chrome Latest, FF Latest and Edge Latest and Mobile same result. Only Edge return : The code on this page disabled back and forward caching. Which I think irrelevant.
  8. Also tried to use FB API V 2.8

Still no joy

Here is my app settings:

App settings

Deauthorize call back setting

That's so funny! Please advice!

Thank you

wpcoder
  • 1,016
  • 11
  • 17
  • What's the actual use case that would require it that this works instantly? Users removing the app while looking at its canvas version is probably not an everyday thing. – CBroe Nov 04 '17 at 09:33
  • Being in local host; when a user deauthorize an app; dosn't make sense to consider that they logged out. Also when they logout from facebook they stay in the app...in development mode I want to see they are out of my app; because I am developing in local host not directly in the canvas...anyway why you think the subscribe.event dosn't fire. On local host it take an hour then it fires! Even in the canvas; it take also an hour if I deauthorize from another page. – wpcoder Nov 04 '17 at 14:18
  • 1
    How does that answer my question, what you actually _need_ this for in the first place? If things go wrong during API calls due to missing permissions or an invalidated access token, the response will tell you. So, the matter of why this does not seem to behave as accurate or timely as you'd like aside - explain where/how that causes an _actual_ problem, please. (And just because you develop on localhost does not mean you can not test it inside the canvas iframe, btw.) – CBroe Nov 04 '17 at 14:23
  • 1-I load the app on canvas. 2-Open new page and go to app setting. 3- deauthorize app. 4-go back to canvas. 5-I can still use the app. is this normal. I am trying to logoff as soon as user deauthorize my app. Same happen when I logout Facebook, it doesn't logout my app....they can go to URL directly and keep using it....(outside canvas) – wpcoder Nov 04 '17 at 14:49
  • Even tried different ISP; it works but takes like an hour! I guess need to report a bug to FB; hope I am wrong somewhere! – wpcoder Nov 04 '17 at 17:19

0 Answers0