密钥散列不匹配而Facebook登录Android中密钥、不匹配、Android、Facebook

2023-09-12 07:56:46 作者:相思赋予我

我的应用程序使用一个简单的Facebook登录。我已经进入了keyhash在我的应用程序仪表板,key_hash部分,我能够成功登录。现在,我已经发布了应用程序,并试图登陆,​​但它显示一个错误信息上的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是不是我的,我在本机应用程序密钥散列。它在哪里来的?反正我进入这个keyhash也是本机应用程序,但得到了同样的错误信息,无法登录还在。凡am'i的问题呢?请帮我。

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.

推荐答案

您可以通过生成编码的哈希键,你只需要做一件事。复制粘贴此code。在主类(第一类),然后运行该应用程序并检查的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) {

}