Need facebook logout if user logout from my application - facebook

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.

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!

(Freshplanet Facebook-ANE) How to make the login screen in-app

I am currently using the Freshplanet Facebook-ANE and was wondering about something that is bugging me currently.
I want to implement a simple post to wall feature inside my app, and this ANE does exactly what I want, except for one thing. When I do the actual post to wall dialog, it pops up just like I want it, in a WebView inside my app. The login takes me to Safari or the Facebook app if I have it installed, which is what I want to avoid.
Here's the line I'm using to open the session :
Facebook.getInstance().openSessionWithPublishPermissions(POST_PERMISSIONS, OnSessionOpened, true);
That works perfectly for posting, but takes me outside of the app.
I've tried using the same .dialog() function I use for the post, and it worked, but I can't seem to post to the wall afterwards (maybe I'm not correctly catching the access token or something)
Any help would be appreciated. I believe I've set up everything correctly on my Facebook App page, and that my AS3 project is correctly setup.
Thanks for the help !
If you want to strictly stay into the app, you must use StageWebView. It's something like a wrapper of HTML page inside Flash.
First check if you are logged in (this is code from Facebook.as of FreshPlanet):
/** True if a Facebook session is open, false otherwise. */
public function get isSessionOpen() : Boolean
{
if (!isSupported) return false;
return _context.call('isSessionOpen');
}
If there is no session - start the web view. Otherwise - continue as usual.
You have to keep in mind that StageWebView is pretty.. how to say it.. bad is the kindest thing I could say :) You must implement your own close button, listen for url changing, etc.
You could look into Facebook AS3 SDK, which at least has some kind of 'platform' for the web view..
Good luck!

FB.Login in Safari doesnt work right

I've got a strange problem. I've programened an facebook app where the user has to connect. when clicking the submit-button the JS has to check if the user has the requested permissions and (if not) requires a connection for the user. This is done via FB.api('/me/permissions', function(response){ }); and FB.Login(); where FB.Login() is fired in the permissionsCheck when the needed permissions aren't granted...
This script works in all Browsers well ... expected Safari! In Safari eh FB.Login()-Function calls via Network the following URL...
http://www.facebook.com/dialog/oauth?api_key=369743*&app_id=369743**&channel_url=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%3Fversion%3D3%23cb%3Dfdcdafb0%26origin%3Dhttp%253A%252F%252Fmypage.com%252Ffb3ecf95c%26relation%3Dparent.parent%26transport%3Dpostmessage&client_id=36974***&display=none&domain=mypage.com&locale=de_DE&origin=1&redirect_uri=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%3Fversion%3D3%23cb%3Df35bd9f80c%26origin%3Dhttp%253A%252F%252Fdev.howoge.mb005.de%252Ffb3ecf95c%26relation%3Dparent%26transport%3Dpostmessage%26frame%3Df50f3d2e8&response_type=token%2Csigned_request%2Ccode&sdk=joey
... and gets redirected to an empty frame with the following source:
https://s-static.ak.fbcdn.net/connect/xd_proxy.php?version=3#cb=f35bd9f80c&origin=http%3A%2F%2Fmypage.com%2Ffb3ecf95c&relation=parent&transport=postmessage&frame=f50f3d2e8&error=unknown_user
When I start the FB.Login() function via console I get the Login Popup perfectly .... -.- So whats the Problem? Why does Facebook doesnt show the Popup via script and (internal) redirects to an error page instead of displaying me the popup (like I called via console)???
I hope somebody may help out.
Thanks in advance :)

Facebook API events fire continuously

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.

redirect on facebook app install

Upon install of my app on a Facebook Page, I'd like to send the user to an URL with further instructions. I'm starting the installation with http://facebook.com/add.php?api_key=app_api_key&page=page_id, which installs but redirects the user to the Facebook Page itself. It seems like various forms of redirect were available at some point:
Post-authorize callback URL. I can no longer find that in App settings.
The next parameter for add.php. I can't seem to get this to work
I have seen some apps that do redirect upon install, so I believe this is possible. Maybe it's using an old Post-authorize setting that's no longer visible?
Any help or point would be greatly appreciated! I'm also not attached to using add.php, if there's a Facebook Connect method that does this I'd use that instead (I'm looking at profile.addtab though that doesn't seem to work either).
You can set the redirect URL in the app properties. You can no longer set it from the developer control panel in Facebook, but you can still set it using the REST api.
The list of app properties is here: http://developers.facebook.com/docs/appproperties/
To set the "post_authorize_redirect_url" you would use something like this:
https://api.facebook.com/method/admin.setAppProperties?
access_token=CURRENTTOKEN&
properties={'post_authorize_redirect_url':'http://mydomain.com/post_authorize_folder/'}
I am not completely clear on this, but I believe the url needs to point to a folder, terminated with "/" rather than a specific file.
The callback gets two parameters:
installed = 1 (true)
fb_page_id = the page id when your app was installed
First page that Canvas is point to should have
< script type='text/javascript'>top.location.href = 'REDIRECT-URL';< /script>
So when your app is opened it will automaticaly redirect to REDIRECT-URL
I'm not sure that you can avoid opening of application canvas page after installing application.