How to force android facebook sdk to re-authenticate

杀马特。学长 韩版系。学妹 提交于 2019-12-24 07:58:33

问题


Short version: I want my app to somehow delete/reset the Facebook Apps on the same device, so that after logout it will always ask people to login in Facebook Apps and forget all the account history to maintain the privacy.

Long version: I am building an android apps that do a specific tasks like this:

  1. The apps will capture an image
  2. The apps will ask user to login into Facebook (e.g. Facebook integration)
  3. The apps will then try to share the captured image via user's Facebook account
  4. The apps will then automatically logout the current user account

I follow Android Facebook SDK documentation to build the login features. It stated that my device must have Facebook Application installed so I did install it, and everything are well.

The image sharing was going well.

But then I want my app to logout the current Facebook Account completely. I followed the answer from here by using the following code:

public void disconnectFromFacebook() {

    if (AccessToken.getCurrentAccessToken() == null) {
        return; // already logged out
    }

    new GraphRequest(AccessToken.getCurrentAccessToken(), "/me/permissions/", null, HttpMethod.DELETE, new GraphRequest
            .Callback() {
        @Override
        public void onCompleted(GraphResponse graphResponse) {

            LoginManager.getInstance().logOut();

        }
    }).executeAsync();
}

It did logout, but the Facebook Account that already logged in at the Facebook Apps will remain intact. Then when another user want to login, a scene like this will popup, indicating that the Facebook Apps save the account history and did not Logged out completely.

Since my Apps will be deployed on public places where people can freely capture photos and share it to Facebook via my Apps, I want my Apps to always Logout the Facebook Account permanently from my device. This means that, when the next people use my Apps I want it to ask a brand new Facebook Login authentication without the Facebook Apps remembering every person that logged to it.

I already try some of the workaround:

  1. I suppress the facebook login to use webview as stated from here, this solution seems to always ask a login authentication, but then it will also redirect to Facebook Apps so it is pointless.
  2. I am thinking to share the image via web application, but not only it will be unable to share automatically using my code, the callback will not reach my application. Plus, the documentation also stated that all sharing task must be done using Facebook SDK.

Sorry should I not compile my question better.

Thanks in advance.


回答1:


Try the verification using web APIs instead of the Personal App, Facebook login with Mobile Application is intended for private users only. Here is a full facebook 4.0.+ login example.



来源:https://stackoverflow.com/questions/44234064/how-to-force-android-facebook-sdk-to-re-authenticate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!