Android Facebook SDK 4.5.0登录注销问题无效的密钥哈希错误,同时尝试再次登录 [英] Android Facebook SDK 4.5.0 Login-Logout Issue Invalid Key Hash Error, While Trying to Login Again

查看:172
本文介绍了Android Facebook SDK 4.5.0登录注销问题无效的密钥哈希错误,同时尝试再次登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照 https://developers.facebook.com中所述实施了Facebook登录按钮/ docs / facebook-login / android 具有配置文件和电子邮件读取权限的开发人员指南。

I implemented Facebook login button as described in https://developers.facebook.com/docs/facebook-login/android developer guide with profile and email read permissions.

当我按登录按钮时,Facebook应用程序打开,然后我可以登录,并可以从Facebook获取用户数据。此后,Facebook按钮将自动切换为注销按钮。当它被按下时,它会退出。到目前为止,它的效果很好。

When i press login button, Facebook app opens up and then I can log in and can get user data from Facebook. After this point, Facebook button turns to Log out button automatically. And when it is pressed, it logs out. So far, it works well.

一旦Facebook在我的应用程序中注销完毕,并且想要使用Facebook按钮重新登录,则Facebook会出现密钥哈希错误。如果我在Facebook应用程序中进行帐户设置,并从列表中删除我的应用程序,则重新登录将返回成功。

Once Facebook log out done in my app side, and want to re-login with Facebook button, Facebook fails with key hash error. If I go to account settings in Facebook app, and remove my app from list then re-login returns success.

我也在这里尝试了解决方案 Android Facebook应用程序注销问题,但它也没有工作。
要清除,我使用这个代码(在AccessTokenCache类中找到共享的pref名称):

I also tried the solution here Android Facebook app logout issue but it didn't work either. To clear, I use this code (found shared pref name in AccessTokenCache class):

   SharedPreferences fbSharedPreferences = this.getSharedPreferences("com.facebook.AccessTokenManager.SharedPreferences", 0);
   if (fbSharedPreferences != null) {
       fbSharedPreferences.edit().clear().commit();
   }

我正在使用Facebook SDK 4.5。我正在用一个真正的Facebook帐户进行测试。我的应用程序键和散列设置在Facebook应用程序设置中。

I'm using Facebook SDK 4.5. I'm testing with a real Facebook account. My app keys and hashes are set in Facebook app settings.

问题标题受 Facebook登录注销问题影响,无效的密钥哈希错误,同时尝试再次登录(没有解决方案)

P.S. Question title is influenced from Facebook Login-Logout Issue Invalid Key Hash Error, While Trying to Login Again (which does not have a solution).

推荐答案

我有同样的问题,您需要从Facebook应用程序中删除应用程序,然后注销。

I was having the same issue, you need to delete app from facebook app and then logout. Following function will do the trick.

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();
}

这篇关于Android Facebook SDK 4.5.0登录注销问题无效的密钥哈希错误,同时尝试再次登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆