remote_app_id does not match stored id - exception
Asked Answered
E

3

3

i am using the facebook native login and i get the CLOSED_LOGIN_FAILED .

The following is the LogCat i get in DDMS ,

    02-22 15:16:22.939: E/exception(4583):  is null
    02-22 15:16:22.939: E/session(4583):  is {Session state:OPENING, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[]}, appId:420081348034777}
    02-22 15:16:22.939: E/state(4583):  is OPENING
    02-22 15:16:51.749: E/exception(4583):  is com.facebook.FacebookOperationCanceledException: remote_app_id does not match stored id 
    02-22 15:16:51.749: E/session(4583):  is {Session state:CLOSED_LOGIN_FAILED, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[]}, appId:420081348034777}
    02-22 15:16:51.749: E/state(4583):  is CLOSED_LOGIN_FAILED
    02-22 15:16:51.749: E/if logged in is(4583):  true : false
    02-22 15:16:51.749: E/if logged in is(4583):  exception : com.facebook.FacebookOperationCanceledException: remote_app_id does not match stored id 
    02-22 15:16:51.749: E/if logged in(4583):  premissions : []

i get the keyhash using

C:\Program Files\Java\jre6\bin>keytool -exportcert -alias androiddebugkey -keystore "c:\documents and settings\Droid 4\.android\debug.keystore" | C:\openssl-0.9.8g_win32\bin\openssl sha1 -binary | C:\openssl-0.9.8g_win32\bin\openssl base64

where "c:\documents and settings\Droid 4\.android\debug.keystore" is my keystore path and C:\openssl-0.9.8g_win32\bin\openssl is my openssl path

this is how i get the key for using it through eclipse and for the keystore i create ,

C:\Program Files\Java\jre6\bin>keytool -exportcert -alias mykeystorename -keystore "D:\Apps\mykeystorepath" | C:\openssl-0.9.8g_win32\bin\openssl sha1 -binary | C:\openssl-0.9.8g_win32\bin\openssl base64

this is the command i use for getting my keyhash , signing with the kaystore i created for publishing .

i dont know where i am going wrong , i have tried through all the related threads and i was not successful .

Thanks in advance .

Exordium answered 22/2, 2013 at 10:18 Comment(0)
R
17

Use this piece of code because is more reliable, i tried many versions of openssl but with no success.

  try {
        PackageInfo info = getPackageManager().getPackageInfo("your.package",
                PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.d("YOURHASH KEY:",
                    Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    } catch (NameNotFoundException e) {

    } catch (NoSuchAlgorithmException e) {

    }

paste it in onCreate

Raber answered 19/3, 2013 at 11:32 Comment(1)
After a day of desperation, and even after i`v seen this answer and decided discard it, i was more than surprise to see that its actually worked! defiantly there is something wrong with openssl, or is it that I (and all the rest who did) didnt get what openssl is for.Acculturation
A
6

I have also got stucked in the same issue and finally got a way around, the main reason behind the wrong Hash Key was the openssl, please download the openssl from here, i think facebook should provide a download link to openssl on their site so that people wont stuck in problems like this

Alanna answered 25/4, 2013 at 10:57 Comment(1)
Thanks that is the problem exactly... I had openssl generate wrong codesReid
H
0

In addition to the above (correct) answers, I realized that when you do a 'release' build (EXPORT) as opposed to a 'debug' build (e.g - just build and run through Eclipse) - the build process uses a different key store. Which means that the hash code is different! I've been running the code above that gave me the hash key, I was able to connect and post, but none of my users were (because they installed from the STORE, which is built using the RELEASE key store!)

SO. Luckily Facebook allows multiple hashes. Pick your favorite method (either the code above or the SSL command line thing) and put BOTH keys in your Facebook admin for your app.

Checkpoint - to make sure you're 'safe' - make sure you have at least 2 keys over there and not just one. If you have one, it means that either your 'debug' builds will fail to connect, or your 'release' builds will.

Horrorstruck answered 20/6, 2013 at 9:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.