Using facebook SDK on Android gives “User logged in as different Facebook user.” error

后端 未结 5 1026
Happy的楠姐
Happy的楠姐 2021-01-31 15:02

I\'m upgrading my use of the Facebook SDK to the latest version. The following code is prety much lifted line by line from Facebook\'s own examples, which can be found here: htt

5条回答
  •  情歌与酒
    2021-01-31 15:20

    A lot of thanks to @sorianiv and @ming-li for their answers! I want to describe my case with more details because it can be helpful for somebody.

    The Facebook SDK creates a shared preferences file called "com.facebook.AccessTokenManager.SharedPreferences". And when user signs in with facebook SDK stores access token, user name and other token info there. My issue was that I didn't call

    LoginManager.getInstance().logOut() 
    

    when user signes out in my app. And the cache in shared preferences was not cleared. So when user than tries to sign in with different Facebook user Facebook SDK got the user data from the cache and returned error:

    "User logged in as different Facebook user.”

    In my case the solution was just to call logOut() when user signs out from my app.

提交回复
热议问题