Android Facebook 密钥哈希不匹配任何存储的密钥哈希

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20301025/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:36:27  来源:igfitidea点击:

Facebook key hash does not match any stored key hashes

androidfacebookfacebook-android-sdkfacebook-sharer

提问by Yenthe

I'm really having troubles with the Facebook hash key. I generated it in my Eclipse.. proof:

我真的遇到了 Facebook 哈希键的问题。我在我的 Eclipse 中生成了它.. 证明:

Then I went to https://developers.facebook.com/and registered a new app.

然后我去了https://developers.facebook.com/并注册了一个新的应用程序。

And finally I've set my hashkey at the settings of Facebook developers:

最后,我在 Facebook 开发人员的设置中设置了我的哈希键:

But no whatter I do I keep getting the same error log: "Key hash B5dWUEYfZJL/...........jyA= does not match any stored key hashes"

但是不管我做什么,我总是收到相同的错误日志:“密钥哈希 B5dWUEYfZJL/...........jyA= 与任何存储的密钥哈希不匹配”

Does anybody know what I did wrong or how I can fix this problem? If I used the id and name from the HelloFacebookSample inside my own app everything works. So it HAS to do with the key hash, id or name I've set somewhere most likely..

有谁知道我做错了什么或者我如何解决这个问题?如果我在自己的应用程序中使用 HelloFacebookSample 中的 id 和名称,一切正常。所以它与我最有可能在某处设置的密钥散列、ID 或名称有关。

Thank you, Yenthe

谢谢你,Yenthe

采纳答案by Yenthe

After hours of trying I've finally found a solution.

经过几个小时的尝试,我终于找到了解决方案。

  1. Delete any app on the website of Facebook (developers.facebook.com)
  2. Delete the file debug.keystore under C:\Users\yourUserName\.android
  3. Generate a new key (by running your app again)
  4. Create a new app on developers.facebook.com and add the new hash key
  5. Re-run your app
  6. Succes!
  1. 删除 Facebook 网站 (developers.facebook.com) 上的任何应用程序
  2. 删除debug.keystore下的文件 C:\Users\yourUserName\.android
  3. 生成新密钥(通过再次运行您的应用程序)
  4. 在 developer.facebook.com 上创建一个新应用并添加新的哈希键
  5. 重新运行你的应用
  6. 成功!

回答by Narender Gusain

If your login is working without installing facebook app and not working when facebook app is installed due to error "hash key has not match" then do following steps

如果您的登录在未安装 facebook 应用程序的情况下正常工作,并且由于错误“哈希键不匹配”而在安装 facebook 应用程序时无法正常工作,请执行以下步骤

1 ) Launch your app and try to log in with facebook. A dialog will open and tell you: "the key has not been found in the facebook developer console and also show the hash key.

1 ) 启动您的应用程序并尝试使用 facebook 登录。将打开一个对话框并告诉您:“尚未在 facebook 开发人员控制台中找到密钥,并显示哈希密钥。

2 ) Note down that hash key.

2 ) 记下该哈希键。

3 ) Put it into your facebook developer console where you first generated your api key and remove the hash key with new and save. Now you are done. Anyone that downloads your app, published with earlier used keystore can log into facebook.

3 ) 将其放入您首先生成 api 密钥的 facebook 开发人员控制台,并使用 new 删除哈希密钥并保存。现在你完成了。任何下载您的应用程序并使用较早使用的密钥库发布的人都可以登录 Facebook。

回答by Darsen Lu

I encountered a similar problem. The solution is surprisingly simple.

我遇到了类似的问题。解决方案出奇的简单。

The error message looks like this:

错误消息如下所示:

07-05 ...... Invalid key hash. The key hash sL1***************VY= does not match any stored key hashes. Configure your app key hashes at http://developers.facebook.com/apps/150*******778
07-05 ......     at com.facebook.login.LoginManager.onActivityResult(LoginManager.java:191)

Simply log into https://developers.facebook.com, select the "Settings" tab, and add the key hash "sL1***************VY=" to the list of saved Key hashes in the Android panel.

只需登录https://developers.facebook.com,选择“设置”选项卡,然后将密钥散列“sL1********************VY=”添加到已保存的列表中Android 面板中的密钥哈希。

回答by Bashar Ali Labadi

I faced the same issue while development and needed to get the hash key to test sharing on facebook, and while solving this I went through couple of issues

我在开发过程中遇到了同样的问题,需要获取哈希键来测试在 facebook 上的共享,在解决这个问题时,我遇到了几个问题

1- the command facebook provide to get the hash key by using openSSL command didn't give me the right hash that I got by extracting the signature from Package info with code. getting the hash by the second way was correct.

1- facebook 提供的使用 openSSL 命令获取散列键的命令没有给我正确的散列,这是通过使用代码从包信息中提取签名而获得的。通过第二种方式获取哈希是正确的。

2- For some reason, In the documentation they tell you to go to developer settings and add the hash key for 'Sample App' there, I thought every hashkey for a developer should be there, and that was my mistake, every app has it's own hash keys field to add to, go to your app/settings/android.

2-出于某种原因,在文档中,他们告诉您转到开发人员设置并在那里添加“示例应用程序”的哈希键,我认为开发人员的每个哈希键都应该在那里,这是我的错误,每个应用程序都有要添加到自己的哈希键字段,请转到您的应用程序/设置/android。

enter image description here

在此处输入图片说明

well that was it.. and for the records I used openssl-0.9.8k_X64 on a Windows 7 x64 bit and it just generates a wrong hash I don't know why

好吧,就是这样......对于我在 Windows 7 x64 位上使用 openssl-0.9.8k_X64 的记录,它只是生成了一个错误的哈希,我不知道为什么

I used this code to get the hash:

我使用此代码来获取哈希:

private void printKeyHash() {
    // Add code to print out the key hash
    try {
        PackageInfo info = getPackageManager().getPackageInfo("YOUR PACKAGE NAME", 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) {
        Log.e("KeyHash:", e.toString());
    } catch (NoSuchAlgorithmException e) {
        Log.e("KeyHash:", e.toString());
    }
}

but be careful that this may not also print in logs the correct keyhash, at least on my device and machine, when I debug it, in a watch it shows the correct hash just before printing the logs, but in logs it shows another hash and the first one was the correct one.

但请注意,这可能不会在日志中打印正确的密钥散列,至少在我的设备和机器上,当我调试它时,在手表中它在打印日志之前显示正确的散列,但在日志中它显示另一个散列和第一个是正确的。

anyway you can also use a command or eclipse to view the SHA hexadecimal sequence for your key and convert it to base 64 online, there are websites that may help http://tomeko.net/online_tools/hex_to_base64.php?lang=en

无论如何,您也可以使用命令或 eclipse 查看密钥的 SHA 十六进制序列并将其在线转换为 base 64,有些网站可能会有所帮助 http://tomeko.net/online_tools/hex_to_base64.php?lang=en

Good luck

祝你好运

回答by Kewal Shah

This is a case that could have possibly occurred and what solved my error:

这是一个可能发生的情况,是什么解决了我的错误:

In the https://developers.facebook.com/quickstartsafter you run

运行后 在https://developers.facebook.com/quickstarts

OSX/Linux:

OSX/Linux:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

Windows:

视窗:

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64

When Enter keystore password:is asked you may have accidentally typed a wrong password, the default password is "android". Typing any other password will give you a different/wrong hash key. Paste the correct hash key in the Key Hashesfield on your app page

Enter keystore password:系统询问您可能不小心输入了错误的密码时,默认密码为“ android”。输入任何其他密码都会给你一个不同/错误的哈希键。Key Hashes应用页面的字段中粘贴正确的哈希键

This solved my problem, hope this helps whoever made this particular error that I made

这解决了我的问题,希望这可以帮助犯了我犯的这个特定错误的人

回答by Peter File

Adding SHA1 keys from Eclipse/keytool helped me only when creating the app on FB, then after rebuilding I would always get the OP error.

从 Eclipse/keytool 添加 SHA1 密钥仅在 FB 上创建应用程序时对我有帮助,然后在重建后我总是会收到 OP 错误。

What solved my issue was adding the key in the error message to the Facebook dashboard settings.

解决我的问题是将错误消息中的密钥添加到 Facebook 仪表板设置中。

回答by Govan

---2019----- This is how i solved this problem

---2019----- 这就是我解决这个问题的方法

  1. in android studio in right panel Gradle>App>android>signingReportcopy SHA1
  2. and open http://tomeko.net/online_tools/hex_to_base64.phpto convert your SHA1 value to base64.

  1. 在右侧面板的 android studio 中 Gradle>App>android>signingReport复制SHA1
  2. 并打开http://tomeko.net/online_tools/hex_to_base64.php将您的 SHA1 值转换为 base64。

This is what Facebook requires get the generated hash " ********************= " and copy the key hash to the facebook app.

这就是 Facebook 需要获取生成的哈希“ ********************= ”并将密钥哈希复制到 facebook 应用程序。

回答by Rezaul Karim

  1. Check your Key hash value.
  2. Uninstall the Facebook application from your phone.
  3. Then try again using SDK.
  1. 检查您的密钥哈希值。
  2. 从您的手机卸载 Facebook 应用程序。
  3. 然后使用 SDK 重试。

This solved my problem.

这解决了我的问题。

回答by Sakramento

I have had this Problem for two months now. My key hashes have been pyling up to 9. Today i finally found the simple solution:

我已经有这个问题两个月了。我的密钥哈希已经达到 9。今天我终于找到了简单的解决方案:

STEP 1:

第1步:

Install the facebook sdk you downloaded from the facebook developer page on your phone. Don′t install the normal facebook app. Make sure you can log into facebook. Then log out.

将您从 facebook 开发人员页面下载的 facebook sdk 安装到您的手机上。不要安装普通的 facebook 应用程序。确保您可以登录 facebook。然后退出。

STEP 2:

第2步:

Export your app with your final release key as an apk, like you would when uploading it to the playstore.

使用最终发布密钥将您的应用导出为 apk,就像将其上传到 Playstore 时一样。

STEP 3:

第 3 步:

Put the Apk file on your phone via usb cable or usb stick.

通过 USB 数据线或 U 盘将 Apk 文件放在您的手机上。

STEP 4:

第四步:

Install your app, using a file manager: For example https://play.google.com/store/apps/details?id=com.rhmsoft.fm

使用文件管理器安装您的应用程序:例如 https://play.google.com/store/apps/details?id=com.rhmsoft.fm

STEP 5:

第 5 步:

Launch your app and try to log in with facebook. A dialog will open and tell you: "the key has not been found in the facebook developer console

启动您的应用程序并尝试使用 Facebook 登录。将打开一个对话框并告诉您:“尚未在 facebook 开发者控制台中找到密钥

STEP 6:

第 6 步:

Write down the key.

写下钥匙。

STEP 7:

第 7 步:

Put it into your facebook developer console and save. Now you are done. Anyone that downloads your app, published with earlier used keystore can log into facebook.

将其放入您的 Facebook 开发者控制台并保存。现在你完成了。任何下载您的应用程序并使用较早使用的密钥库发布的人都可以登录 Facebook。

Enjoy

享受

回答by Pratap Sharma

Follow these steps in order to generate the correct key hashes.

请按照以下步骤生成正确的密钥哈希。

  1. Open your project in android studio and run the project.
  2. Click on Gradle menu.
  3. Select your app and expand task tree.
  4. Double click on android -> signingReport and see the magic Sample Image
  5. Result after clicking above tab Result after clicking above tab
  6. Copy the SHA1 key and browse SHA1 key to key hash
  7. After converting the SHA1 key to key hash copy the new key hash and paste it in facebook console. This will work like charm.
  1. 在 android studio 中打开您的项目并运行该项目。
  2. 单击 Gradle 菜单。
  3. 选择您的应用程序并展开任务树。
  4. 双击 android ->signingReport 并查看魔术 示例图像
  5. 单击上面的选项卡后的结果 单击上面的选项卡后的结果
  6. 复制 SHA1 密钥并浏览SHA1 密钥到密钥哈希
  7. 将 SHA1 密钥转换为密钥散列后,复制新的密钥散列并将其粘贴到 Facebook 控制台中。这将像魅力一样工作。