Reputation: 356
My application asks for facebook authorization and so it was working fine with webview. I haven't install fb on my android device. Using fbsdk 3.5
Just to test fb application auth flow, I downloaded fb android application and logged in successfully.
Then I tried my app to use android fb app auth instead of webview but it fails with this error
Bad thing happened UnknownError: ApiException:Key hash pBc2****************MwM does not match any stored key hashes.
I uninstall fb android app and tried doing auth using webview it worked.
FB app auth gave me error on first time here is trace
01-31 14:22:32.129: W/Bundle(3897): Key com.facebook.platform.protocol.PROTOCOL_VERSION expected String but value was a java.lang.Integer. The default value <null> was returned.
01-31 14:22:32.149: W/Bundle(3897): Attempt to cast generated internal exception:
01-31 14:22:32.149: W/Bundle(3897): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
01-31 14:22:32.149: W/Bundle(3897): at android.os.Bundle.getString(Bundle.java:1069)
01-31 14:22:32.149: W/Bundle(3897): at android.content.Intent.getStringExtra(Intent.java:4768)
01-31 14:22:32.149: W/Bundle(3897): at com.facebook.AuthorizationClient$KatanaLoginDialogAuthHandler.tryAuthorize(AuthorizationClient.java:821)
01-31 14:22:32.149: W/Bundle(3897): at com.facebook.AuthorizationClient.tryCurrentHandler(AuthorizationClient.java:272)
01-31 14:22:32.149: W/Bundle(3897): at com.facebook.AuthorizationClient.tryNextHandler(AuthorizationClient.java:238)
01-31 14:22:32.149: W/Bundle(3897): at com.facebook.AuthorizationClient$GetTokenAuthHandler.getTokenCompleted(AuthorizationClient.java:772)
01-31 14:22:32.149: W/Bundle(3897): at com.facebook.AuthorizationClient$GetTokenAuthHandler$1.completed(AuthorizationClient.java:731)
01-31 14:22:32.149: W/Bundle(3897): at com.facebook.internal.PlatformServiceClient.callback(PlatformServiceClient.java:144)
01-31 14:22:32.149: W/Bundle(3897): at com.facebook.internal.PlatformServiceClient.handleMessage(PlatformServiceClient.java:128)
01-31 14:22:32.149: W/Bundle(3897): at com.facebook.internal.PlatformServiceClient$1.handleMessage(PlatformServiceClient.java:54)
01-31 14:22:32.149: W/Bundle(3897): at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 14:22:32.149: W/Bundle(3897): at android.os.Looper.loop(Looper.java:137)
01-31 14:22:32.149: W/Bundle(3897): at android.app.ActivityThread.main(ActivityThread.java:5283)
01-31 14:22:32.149: W/Bundle(3897): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 14:22:32.149: W/Bundle(3897): at java.lang.reflect.Method.invoke(Method.java:511)
01-31 14:22:32.149: W/Bundle(3897): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
01-31 14:22:32.149: W/Bundle(3897): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
01-31 14:22:32.149: W/Bundle(3897): at dalvik.system.NativeStart.main(Native Method)
I dig up the fB sdk and this is what at line 821
Intent intent = NativeProtocol.createLoginDialog20121101Intent(context, request.getApplicationId(),
new ArrayList<String>(request.getPermissions()),
request.getDefaultAudience().getNativeProtocolAudience());
if (intent == null) {
return false;
}
and here is createLoginDialog20121101Intent
public static Intent createLoginDialog20121101Intent(Context context, String applicationId, ArrayList<String> permissions,
String audience) {
Intent intent = new Intent()
.setAction(INTENT_ACTION_PLATFORM_ACTIVITY)
.setPackage(FACEBOOK_PACKAGE)
.addCategory(Intent.CATEGORY_DEFAULT)
.putExtra(EXTRA_PROTOCOL_VERSION, PROTOCOL_VERSION_20121101)
.putExtra(EXTRA_PROTOCOL_ACTION, ACTION_LOGIN_DIALOG)
.putExtra(EXTRA_APPLICATION_ID, applicationId)
.putStringArrayListExtra(EXTRA_PERMISSIONS, ensureDefaultPermissions(permissions))
.putExtra(EXTRA_PROTOCOL_CALL_ID, generateCallId())
.putExtra(EXTRA_WRITE_PRIVACY, ensureDefaultAudience(audience));
return validateKatanaActivityIntent(context, intent);
}
EDIT: Also tried Facebook SDK 3.6 didn't help
I don't find anything suspicious here. Need help to sort this out.
Thanks.
Upvotes: 0
Views: 659
Reputation: 28484
For Linux
Open Terminal :
For Debug Build
keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64
you wil find debug.keystore from ".android" folder copy it from and paste on desktop and run above command
For release Build
keytool -exportcert -alias <aliasName> -keystore <keystoreFilePath> | openssl sha1 -binary | openssl base64
NOTE : Make sure In Both case it must ask for password. If it does not asks for password that means something is wrong in command.
Now go to -> https://developers.facebook.com
-> Click on "Apps"
-> Select Your App
-> Click on "Settings" on left tab
-> Under "Android" Section you will find input field "Key Hashes"
-> Put the generated hashkey there and save changes.
Upvotes: 2