Facebook API events fire continuously - facebook

I am using the following example from the facebook website to have a user logon and get his details: https://developers.facebook.com/blog/post/481
I am encountering two problems:
1) The auth.sessionChange event gets fired every half a second, and the page reloads accordingly every half a second (because of this code: FB.Event.subscribe('auth.sessionChange', function(response) {
window.location.reload();
});)
2) When the user clicks login, the login windows doesn't close upon successful login - but nothing happens instead.. After logging in in the popup window, the login page turns into a white blank page..

In your Application Settings, make sure you set your Site URL and Site Domain.
Did you also make sure to update the App Id from your Applications settings in the code?
Last, are you using Safari that could possibly have session caching or cookies disabled? Having done a bunch of Facebook Applications, I can tell you that if you have cookies disabled, you're in some trouble.
I just went through the example, copy-pasted, created a test app, and it works perfectly (tested in Chrome.) Open up Charles, and make sure it's connecting to facebook.com/extern/login_status.php with the proper app id.

Related

How to prevent Auth0 to redirect after logout (ionic app)

I am working on an Ionic 6 app that uses Auth0 for authentication. We are using the embedded login strategy and auth0-js as the client library to talk with auth0.
I've reached to the point where everything works nice if I serve the app on an emulator via ionic serve. I can login and logout effortlessly, and authjs' logout method, which I'm calling as follows:
public logout() {
store.dispatch('endSession');
this.endSession();
this.webAuth.logout({
returnTo: process.env.VUE_APP_LOGOUT_CALLBACK,
clientID: clientId,
});
}
Does redirect me to http://localhost:3000/login as intended (that's the value of VUE_APP_LOGOUT_CALLBACK).
However, when I compile the app and launch it on a mobile phone (I'm using android studio) I have the following problem:
My current problem
After calling WebAuth.logout, the app stops and a browser tab pointing to localhost:3000/login tries to open as if it was a website I'm navigating to. But the behavior I want is for the app to return to the login page, of course.
Other users seem to have found the same issue:
https://community.auth0.com/t/logout-on-ionic-3/20222/9
https://community.auth0.com/t/impossible-to-redirect-user-after-logout-ionic-angular/82205
But no one really solved the issues in those threads. I had no luck finding more resources related to this.
What I've tried
I've tried changing the redirect route to capacitor://localhost/login, hoping it's a way to tell the ionic shell to navigate inside the context of the app, but it didn't work.
I've tried to avoid passing redirectTo as an option to WebAuth.logout(). This makes the method to redirect to the first URL set up on the Auth0 dashboard allowed logout URL, as far as I know.
I've played with a lot of different URL's as returnTo, like / or /login, but it didn't work as I expected and the browser always tries to open such URL as a new website, instead of navigating in the context of the running app.
What would be the ideal outcome
I'd like the app to return to /login, which is the first view the user encounters when they launch the app on the phone.
If that's not possible, maybe it would be possible to just get Auth0 to not redirect at all, so I can perform the redirect by myself and send the user back to the login page.
Maybe there's a way to tell my app not to ever redirect to the redirectUri, even if there's no way for auth0 to avoid trying to redirect the app to another page? Auth0-js docs don't suggest any way to avoid the redirect, but maybe there's a way via ionic config or javascript to make sure the app won't ever redirect to a certain URL.
Thanks for your time!

Facebook gives security warning: Please treat the URL above as you would your password and do not share it with anyone

I have integrated Facebook with my application to post content. It was working until version 1.2 of the application, but now I am getting a security warning just after login as bellow.
The weird thing about this security warning is that it works for one of my Facebook accounts properly without any warning as previously, but I get this warning with my other account. I have attached a screen shot of the issue:
Disabling the secure browsing is not worth , as we cant make all the users to disable secure browsing.
I do have resolved.Check my answer here. Escape from Facebook security Warning
After a long time spend on Internet to search this issue. Finally I got the answer about it.
Login to Facebook account > Go to Privacy Setting > Click on Security tag on left side of Page > then Disable Secure browsing
Now Reset your simulator and and then Run application and again login it will work for sure
Short answer is that the problem can be solved if you use your own redirect_uri rather than the standard facebook one. When the access token is returned, the standard www.facebook.com/connect/login_success.html page has a timer which will change the URL possibly before your app can retrieve the access token.
This problem can occur related to internet latency. We had two customers report issues with this one in Myanmar and one in the UK. No issues for anyone else. Assuming you are authorizing like this:
https://www.facebook.com/v2.10/dialog/oauth?client_id=999999999999999&redirect_uri=https://www.facebook.com/connect/login_success.html&response_type=token&scope=user_photos,user_events&display=popup
For the default redirect_uri (https://www.facebook.com/connect/login_success.html), facebook returns the access_token in the parameters of the URL, but the html body for that page contains two timers:
Success <br/>
<b id="warning" style="display: none; color:red">
SECURITY WARNING: Please treat the URL above as you would your password and do not share it with anyone.
See the Facebook Help Center for more information.
</b>
<script type="text/javascript">
document.domain = 'facebook.com';
if (window == top) {
setTimeout(function () { document.getElementById("warning").style.display = "block"; }, 2000);
}
setTimeout(function () { if (window.history.replaceState) { window.history.replaceState({}, "", "\/connect\/blank.html#_=_"); } }, 2000);
</script>
When either timer fires, it will change the URL which removes the access_token. So as long as you catch that before it changes, everything works. In our case, we were using an embedded browser control under Windows and monitoring the navigated links. As long as the code can receive a navigation event containing the access_token before this timeout occurs, then everything worked. We were never able to determine how latency of the internet connection and possibly some combination of a user's slow computer caused this problem, but this solved it.
In the Facebook Login settings for your facebook app, add your own URIs to the list of Valid OAuth redirect URIs. If you redirect to your own html page, then you can avoid the facebook timeout.

Facebook Like button cyclically opens and closes a popup window, facebook.com/connect/connect_to_external_page_widget_loggedin

I associated a Facebook account with my GaiaOnline account; we use Connect to accomplish this. I created a JS Like button for a page at FB's dedicated page: developers.facebook.com/docs/reference/plugins/like
The Like button's code was
Upon clicking the Like button in XP/firefox 3.6.13, while logged into Gaia and FB, a popup window rapidly opens and closes cyclically until the process is terminated. This behavior is not repeatable on other windows machines, macs or chrome. Presumably this is Facebook trying to initiate a FB login page, per their third-party login process: developers.facebook.com/blog/post/312
My history identifies this page as "http://www.facebook.com/connect/connect_to_external_page_widget_loggedin.php?social_plugin=like&external_page_url=http%3A%2F%2Ftest135.open.dev.gaiaonline.com%2Fforum%2Fentertainment-discussion%2Fthe-roommate-what-s-the-best-thing-about-having-a-roommate%2Ft.67947263%2F".
A video of this transpiring is uploaded to Youtube: http://www.youtube.com/watch?v=1asJ4kMNL6w
What is causing the popup behavior, and what can be done to fix it?
Try enabling 3rd party cookies
http://support.mozilla.com/kk/questions/761194#answer-127335

Facebook Authorise with Facebook SDK

I'm using the Facebook SDK on a .net 4 MVC 2.0 website. I've managed to get everything set up ok as per the sample app and I can go to my facebook app page and see my page. However when going to the About page I've been asked to allow my application to access my details, which I did, then the page just redirects to my Index page. If I click on the About tab and debug the application the About Action never gets called, it's always the Index Method.
Here's the About Method on the controller:
[FacebookAuthorize()]
public ActionResult About()
{
//Some code in here
}
So, I tried to removing the FacebookAuthorise attribute and I got this error:
(OAuthException) An active access token must be used to query information about the current user.
Have I set something up wrong somewhere whereby the cookie isn't being read or the authorisations can't take place? I've got the enable cookie set to true in the web.config for the facebookSettings.
You shouldn't be using the FacebookAuthorize attribute inside an iframe app. You should use CanvasAuthorize. Authorization is different depending on if you are in a iframe or a regular web app. Change that and it should work correctly.

Need facebook logout if user logout from my application

In my joomla application I am facing a problem . user can log in my application through facebook ,but I want whenever user log out from my application, it must be log out from facebook account too.
Please give me your suggestion or any idea how can i do this?
Thanks
I assume you're using Facebook Connect?
If so, just do the following in JavaScript:
FB.Connect.logout(); // old JS API
FB.logout(); // new JS API
http://developers.facebook.com/docs/reference/javascript/FB.logout
http://developers.facebook.com/docs/reference/oldjavascript/FB.Connect.logout
Are you redirecting to another page along with or immediately after the FB.logout call?
I have found that FF and Chrome will execute the FB.logout call quickly enough for this to work properly but that IE and mobile browsers (because of network speed in addition to differences in the JavaScript engine) will not complete the call successfully before the browser loads whatever page you're redirecting to.
So, the safest thing is to put any redirect into a callback function and pass that to FB.logout like this:
function mysignout(url)
{
FB.logout(function()
{
top.location.href = 'url'
});
}
I was originally putting FB.logout directly in the onclick event of an anchor link and while that worked in FF and Chrome it did not work in IE or in my Android browser. Doing the above made it work in all environments.
Surprisingly, it take 2+ seconds for FB.logout to completely successfully in most environments. There is obviously some kind of ajax call involved to revoke authentication on the server, not just destroying the local cookie.