0

I have done all the steps to link my app with fb login. I have made my app live on Facebook Developers. Also I generated the developers key & release key and added it to fb developers site.

Problem: When I log into my app using fb for the first time, it logs in successfully. But now if I logout and try to login again it shows the "Invalid key hash" error on the phone. I know that if I add the key hash shown in the phone to fb developers site, it will work. But what if it shows same error on other phones and adding the key hashes for all the phones is not efficient. So my question is Do I have to add key hashes for all the phones to avoid such error? or Is there any other solutions?

p.s. I have looked the related questions in the StackOverflow but can't find the solution for my problem.

dazed'n'confused
  • 231
  • 3
  • 13

2 Answers2

0

Register your call back by following code.

loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
    @Override
    public void onSuccess(LoginResult loginResult) {
        // App code
    }

    @Override
    public void onCancel() {
        // App code
    }

    @Override
    public void onError(FacebookException exception) {
        // App code
    }
});

You will see the exception in onError(). in exception you will see the error like below

Invalid key hash. The key hash ****************8k1SAmeHM= does not match any stored key hashes. Configure your app key hashes at https://developers.facebook.com/apps/441102912975695/

Copy the key hash provided in log and set to your app will done your work.

Android Dev
  • 1,496
  • 1
  • 13
  • 25
0

Follow steps given in below link. You will get a hash key and add it in your Facebook app settings. This will not give you an error for not matching hash key each time.

Key hash for Android-Facebook app

Pradnya Sinalkar
  • 1,116
  • 4
  • 12
  • 26