在 android 中登录 Facebook 时密钥哈希不匹配 [英] Key hash doesn't match while facebook login in android

查看:51
本文介绍了在 android 中登录 Facebook 时密钥哈希不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用简单的 Facebook 登录.我已经在我的应用程序仪表板的 key_hash 部分中输入了 keyhash,并且能够成功登录.现在我已经发布了应用程序并尝试登录,但它在 webview 上显示一条错误消息,说

My app uses a simple facebook login. I have entered the keyhash in my app dashboard, key_hash section and I was able to login successfully. Now I have published the app and tried to login, but it is showing a error message on a webview saying that

"Invalid android_key parameter. The key rX6qeRitkFCWui3de74rxB_qc1s does not match any allowed key. Configure your app key hashes at http://developers.facebook.com/apps/<my_fb_app_id>". 

实际上 rX6qeRitkFCWui3de74rxB_qc1s 不是我在本机应用程序中拥有的密钥哈希.它来自哪里?无论如何,我也在本机应用程序中输入了此密钥哈希,但收到相同的错误消息并且仍然无法登录.我哪里错了?请帮我.

Actually rX6qeRitkFCWui3de74rxB_qc1s is not my key hash which i have in native app. Where is it coming from? Anyways I entered this keyhash also in native app but getting the same error message and couldn't login still. Where am'i going wrong? Please help me.

推荐答案

你可以通过编码生成哈希键,你只需做一件事.将此代码粘贴到主类(第一类)中,然后运行应用程序并检查 logcat,您将在其中找到哈希键.

You can generate a hash key through coding, you simply do one thing. Paste this code in main class (first class) then run the app and check the logcat where you will find the hash key.

还有一件事,用你的包名替换这个包名com.example.creeper":

One more thing, replace this package name "com.example.creeper" with your package name:

try{
        PackageInfo info = getPackageManager().getPackageInfo(
                "com.example.creeper", PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.d("KeyHash:",Base64.encodeToString(md.digest(), Base64.DEFAULT));       

        }
    } catch (NameNotFoundException e) {

    } catch (NoSuchAlgorithmException e) {

}

这篇关于在 android 中登录 Facebook 时密钥哈希不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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