gpt4 book ai didi

android - Facebook SDK 3.5 通过应用程序登录不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 10:21:39 25 4
gpt4 key购买 nike

我现在很迷茫。我尝试从我的应用程序登录 Facebook。当没有安装 native FB 应用程序时,这工作正常。我获得了访问 token 并可以使用它。但是如果设备已经安装了 facebook 应用程序并且该应用程序在登录请求时启动,我不会获得具有以下异常的访问 token

11-11 11:10:50.510: W/System.err(19215): com.facebook.FacebookAuthorizationException: UnknownError: ApiException:Key hash Djug8pU5w1DRPIxRaRf2N-4JniU does not match any stored key hashes.
11-11 11:10:50.510: W/System.err(19215): at com.facebook.Session.handleAuthorizationResult(Session.java:1078)
11-11 11:10:50.510: W/System.err(19215): at com.facebook.Session.onActivityResult(Session.java:554)
11-11 11:10:50.510: W/System.err(19215): at com.lochmann.fb.viergewinntmultiplayer.MainActivity.onActivityResult(MainActivity.java:266)
11-11 11:10:50.510: W/System.err(19215): at android.app.Activity.dispatchActivityResult(Activity.java:5322)
11-11 11:10:50.510: W/System.err(19215): at android.app.ActivityThread.deliverResults(ActivityThread.java:3363)
11-11 11:10:50.510: W/System.err(19215): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3410)
11-11 11:10:50.510: W/System.err(19215): at android.app.ActivityThread.access$1100(ActivityThread.java:141)
11-11 11:10:50.510: W/System.err(19215): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
11-11 11:10:50.510: W/System.err(19215): at android.os.Handler.dispatchMessage(Handler.java:99)
11-11 11:10:50.510: W/System.err(19215): at android.os.Looper.loop(Looper.java:137)
11-11 11:10:50.510: W/System.err(19215): at android.app.ActivityThread.main(ActivityThread.java:5103)
11-11 11:10:50.510: W/System.err(19215): at java.lang.reflect.Method.invokeNative(Native Method)
11-11 11:10:50.510: W/System.err(19215): at java.lang.reflect.Method.invoke(Method.java:525)
11-11 11:10:50.510: W/System.err(19215): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-11 11:10:50.510: W/System.err(19215): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-11 11:10:50.510: W/System.err(19215): at dalvik.system.NativeStart.main(Native Method)
11-11 11:10:50.510: W/System.err(19215): com.facebook.FacebookAuthorizationException: UnknownError: ApiException:Key hash Djug8pU5w1DRPIxRaRf2N-4JniU does not match any stored key hashes.
11-11 11:10:50.510: W/System.err(19215): at com.facebook.Session.handleAuthorizationResult(Session.java:1078)
11-11 11:10:50.510: W/System.err(19215): at com.facebook.Session.onActivityResult(Session.java:554)
11-11 11:10:50.515: W/System.err(19215): at com.lochmann.fb.viergewinntmultiplayer.MainActivity.onActivityResult(MainActivity.java:266)
11-11 11:10:50.515: W/System.err(19215): at android.app.Activity.dispatchActivityResult(Activity.java:5322)
11-11 11:10:50.515: W/System.err(19215): at android.app.ActivityThread.deliverResults(ActivityThread.java:3363)
11-11 11:10:50.515: W/System.err(19215): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3410)
11-11 11:10:50.515: W/System.err(19215): at android.app.ActivityThread.access$1100(ActivityThread.java:141)
11-11 11:10:50.515: W/System.err(19215): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1304)
11-11 11:10:50.515: W/System.err(19215): at android.os.Handler.dispatchMessage(Handler.java:99)
11-11 11:10:50.520: W/System.err(19215): at android.os.Looper.loop(Looper.java:137)
11-11 11:10:50.525: W/System.err(19215): at android.app.ActivityThread.main(ActivityThread.java:5103)
11-11 11:10:50.525: W/System.err(19215): at java.lang.reflect.Method.invokeNative(Native Method)
11-11 11:10:50.525: W/System.err(19215): at java.lang.reflect.Method.invoke(Method.java:525)
11-11 11:10:50.525: W/System.err(19215): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-11 11:10:50.525: W/System.err(19215): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-11 11:10:50.525: W/System.err(19215): at dalvik.system.NativeStart.main(Native Method)

我确实认为我得到了正确的哈希键,因为:

public static String getKeyHash(Context context) {
String returner = "";
try {
PackageInfo info = context.getPackageManager().getPackageInfo(
"com.lochmann.fb.viergewinntmultiplayer", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
returner = Base64.encodeToString(md.digest(), Base64.DEFAULT);
Log.e("MY KEY HASH:",
Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
e.printStackTrace();
Log.e("ERROR", "NO NAME");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
Log.e("ERROR", "NO ALGO");

}
return returner;
}

返回 11-11 11:10:42.445: E/MY KEY HASH:(19215): 2jmj7l5rSw0yVb/vlWAYkK/YBwk=

我在 FB 后台的设置是这样的:

enter image description here

有没有人给我提示,我做错了什么或者我可以尝试什么?

提前致谢。

最佳答案

如果您在 Activity 之外调用该方法,它总是返回错误的 key 散列 [2jmj7l5rSw0yVb/vlWAYkK/YBwk=]。尝试在您的 Activity (oncreate)中打印它。实际上不知道为什么,但它对我有用。希望这对某人有帮助..

关于android - Facebook SDK 3.5 通过应用程序登录不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19903890/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com