Facebook logout not working

Hi,

I am following the implementation from the following plugin to integrate Facebook login in my application.
Facebook Login for Reactive Web App - Overview | OutSystems 

I am able to fetch relevant user information using this. But plugin doesn't provide information on how to logout of Facebook successfully.

I have placed the Facebook login button in my application and clicking on which I am redirecting the user to the following link.

"https://www.facebook.com/v5.0/dialog/oauth?client_id="+AppId+"&redirect_uri="+RedirectUri+"&state="+State+"&response_type=code&auth_type=rerequest&scope=email,user_birthday,user_hometown,user_gender"

After successful authentication it will get redirected to the redirect_uri specified. The redirect_uri will be one screen in my application. I will get the code as input parameter to that page from Facebook. Once I have code, I will hit the rest api to get access_token with the code. When I get the access_token I am hitting the rest of the graph api to get relevant information. 

But I am not able to logout of Facebook. I tried using FBLogout action in FBLoginPlugin. But it is not working.


I also tried using the FB.init() and FB.logout() functions Facebook JavaScript SDK. It also didn't worked

FB.init({
  appId : '{app-id}',
  coookie : true,
  xfbml : true,
  version : '{api-version}'
});

FB.logout(function(response) {
});

FB.logout() not working. I added an alert inside the logout function to test. But its not showing up.

My requirement is that after I logout of Facebook, again when I tap on 'Login with Facebook' button, it should ask me again for Facebook username and password to login. Now it is not happening. I am directly getting redirected to the home page with the code.

Can anybody please help me with this?  

Thanks,

Sundeep S

mvp_badge
MVP

Hi Sandeep,

I think you are not logged out because this is the default behaviour of facebook login. This component is developed using manual login flow implementation as explained here.

https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow

If you check the facebook login button that also follow same behaviour. Here is the reference link to check.

https://developers.facebook.com/docs/facebook-login/web/login-button/

So I am not sure why you want to do logout from facebook after login.

Hi Nikhil,

Thanks for the quick reply.

I will explain my requirement here. 

Actually the login flow is working as expected. I have a "Login with Facebook" button which allows me to login to FB. And, once I receive the Facebook information I am saving those details in local database. After sometime, if I want to logout from the application, I have a logout button in the application. When I click the logout button it should log me out of the application and it will redirect me again to the screen where I have the "Login with Facebook" button. When I click on the button again it should show me the Facebook login page. But now it is allowing me in with out showing the Facebook login page.


mvp_badge
MVP

Hi Sandeep,

Yes, it will not show you facebook login page when you logout from your application and try to login again.

Reason behind this is that you have logged out from your application not from facebook account.

So when you click on login with facebook again it will redirect you to facebook and because you are already login and given concent to the application to access your data so facebook will automatically send you back to the redirect url without asking to login again.

This is same as if you login to facebook in another browser tab and then click login with facebook in your application, you will be redirected back to your application without showing facebook login screen.

You are correct Nikhil.

This is working fine as well. I have a "Login with Facebook" button. First time up on tapping that it will take me to Facebook login page and I can enter my credentials to login  and fetches all the data needed. Again when I relaunch the application and tap on the "Login with Facebook" button, it will not ask for Facebook credentials and directly logs in and fetches all the required data. This is fine.

What I need is to have a button in the application to logout of Facebook. Up on tapping that, it should log me out of Facebook(Should clear the Facebook related session in the app). So that next time when I relaunch the app and tap on Login with Facebook button, it should show me Facebook login screen to logout

Is there a way to do this?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.