Facebook API login fails with FB app installed on phone

前端 未结 5 2302
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 16:10

I am building an app, which is going to have support for facebook. I have downloaded facebook API and their sample called \"Hackbook\" from original Git repos. The problem i

相关标签:
5条回答
  • 2020-12-02 16:35

    In my case the problem was that the user-login gets cancelled when the facebook app is installed on the device even after generating right keys.

    I added following line before login and it works great.

    LoginManager.getInstance().logOut();
    
    0 讨论(0)
  • 2020-12-02 16:46

    Get you hash key using this function for both(debug and release apk) and put it in your app in developer.facebook.com/apps

    private void calculateHashKey(String yourPackageName) {
        try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    yourPackageName,
                    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) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
    }
    

    this help me a lot.. Hope this will help you too..

    0 讨论(0)
  • 2020-12-02 16:47

    I had a similar problem. In my case, I had not created a hash key using my signing key. I just had the one hash key created using the debug.keystore default signing key.

    As soon as i created a hash key using my app release signing key, that problem was sorted out. If you haven't already done this, create a new hash key using your signing key (for uploading on the market) and add that to your app's facebook control panel.

    Hope this helps.

    0 讨论(0)
  • 2020-12-02 16:54

    I have fixed this issue . After getting Key hash by using keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64 I have logged in first time in release mode successfully... Then second time i got the common error Your key "*********real*key************" does not match the allowed keys specified in your application settings.

    Just use the "*********real*key************" which Facebook gives in error message I logged in successfully now in release mode. So be sure while entering this key that you use the exact same key. The LETTERS I , small(L) i.e (l) will make you in trouble. I made two keys , in the first key I've used small(L) i.e (l) and in second key I've used I. and placed these keys in developer app.
    It is working now ....

    0 讨论(0)
  • 2020-12-02 17:00

    I have toiled for two days & got the solution at last, this is the WRONG way to get the hash key -

    keytool -exportcert -alias *<your _alias_name>* -keystore *<key_store_path>* | [openssl_bin_directory]\openssl sha1 -binary | [openssl_bin_directory]\openssl base64
    

    The right way is type these 3 lines, one at a time in cmd. After the first line, you'll be asked to insert the keystore password.

    keytool -exportcert -alias *<your _alias_name>* -keystore *<key_store_path>* > [openssl_bin_directory]\debug.txt
    [openssl_bin_directory]\openssl sha1 -binary [openssl_bin_directory]\debug.txt > [openssl_bin_directory]\debug_sha.txt
    [openssl_bin_directory]\openssl base64 -in [openssl_bin_directory]\debug_sha.txt > [openssl_bin_directory]\debug_base64.txt
    

    If you want to know details, the RIGHT way is described here -

    http://facebook.stackoverflow.com/questions/13281913/app-is-misconfigured-for-facebook-login-with-release-key-hash

    or here

    Facebook Android Generate Key Hash

    0 讨论(0)
提交回复
热议问题