Android Facebook integration with invalid key hash
Asked Answered
U

30

242

In one of my apps I need to get data from Facebook... I am doing this:

I have created app ID. It logs in successfully, but after logging out, I log in, and then it gives me:

Screenshot of invalid key hash error Facebook

What is wrong I am doing? I am using the Facebook SDK... I have installed Facebook on my phone... It is running well within an emulator, but that does not have the inbuilt Facebook application installed.

This is my code:

if (FB_APP_ID == null) {
    Builder alertBuilder = new Builder(this);
    alertBuilder.setTitle("Warning");
    alertBuilder.setMessage("A Facebook Applicaton ID must be " +
                            "specified before running this example: see App.java");
    alertBuilder.create().show();
}

// Initialize the dispatcher
Dispatcher dispatcher = new Dispatcher(this);
dispatcher.addHandler("login", LoginHandler.class);
dispatcher.addHandler("stream", StreamHandler.class);
dispatcher.addHandler("logout", LogoutHandler.class);

// If a session already exists, render the stream page
// immediately. Otherwise, render the login page.
Session session = Session.restore(this);
if (session != null) {
    dispatcher.runHandler("stream");
}
else {
    dispatcher.runHandler("login");
}
Uhf answered 15/5, 2014 at 9:22 Comment(12)
You must need to generate keyhash and give that value to your Facebook Developer Account. I think you dont have an idea to generate it..right?Nourishing
go to this for Best ExplanationSammie
but it runs fine for first time ligin it not working if i am log in after logout doneUhf
@Pragna have you declare hashkey or not? first let me knowNourishing
yes i have.. created using try { PackageInfo info = getPackageManager().getPackageInfo( "com.facebook.samples.hellofacebook", 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)); }Uhf
and that i have put in developer/facebookUhf
first time login done and get also i am getting but after logout it says me invalid keyhashUhf
I soved this problem here! Here understanded cool![#5306509 ][1]Fini
Hi am also got the same issuee like after login with facebook showing invalid keyhash.am doing every thing same for keytool and hash key generation i dont know even google maps also showing invalid apikey but am getting hash key that i integrated in developer siteChaparral
@Uhf Even though this is old, but I should mention this. This does not happen when a user logout and then login. This happen when you debug the second time i.e. reinstall the app while debugging. Thus, the hash changes. This doesn't happen in case of signed app(production ready)Pressor
Do you get the same error if you uninstall the Facebook App? I tested from two phones and this error only occurs when the Facebook App is installed.Ligamentous
Please look to this link it may help you [Facebook Login for Android App with release key ](https://mcmap.net/q/21229/-facebook-login-for-android-app-with-release-key)Lounging
M
289

The generated hash key is wrong. You may get the hash key using two steps.

One is through a command prompt. Another one is through coding. The hash key through a command prompt is working on the first time only. I don't know the reason. I have also got the same problem. So I tried it through programmatically.

Follow these steps:

Paste the following code in oncreate().

try {
    PackageInfo info = getPackageManager().getPackageInfo(
                           "com.example.packagename",
                           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) {
}
catch (NoSuchAlgorithmException e) {
}

Modify "com.example.packagename" with your package name in the above coding without fail (you may find your package name in the Android manifest file).

Run your application. Go to the activity where you pasted the above code. In the LogCat file, search for "KeyHash". You may find a key hash. Copy the key hash and go to Facebook application dashboard page. Go to settings and enter the details like in the below image.

Enter image description here

Once you finished the above step, relaunch the app again. You may now log into Facebook. For more details about key hash, check the link.

If you add wrong information in the settings page, it means it will give some error. So use the correct information there. And also if the public (other than you) need to use your application means you need to enable the permission (change "yes" in the "Status & Review" next to the setting).

Marje answered 26/5, 2014 at 5:12 Comment(8)
By this way, most likely you got a key hash for debug keystore. It works for you in development mode, not necessary works for your production mode. At least, it doesn't work for my production app.Weekender
Hey by this code PackageInfo info = getPackageManager().getPackageInfo( "com.example.packagename", 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)); a different hash key is sent while when i ran the command in cmd on windows my hash key was different and i have added it in FB but still the log shows the hash of the programatic codeCove
I generated the Key Hash through command prompt on the desktop and added to the facebook dashboard, but the error persists...Hash
I have 2 doubts. One: Can we delete the above code from onCreate method after we note the Key Hash? Two: Will this Key Hash work in released apps (for apps in playstore) ?Pignut
@NimmagaddaGowtham 1. I hope you can. because that block of code is to get the hash key used to built the apk. 2. No it won't work. Because you'll use a different keystore to generate the release apk. so the key hash will be different for that. You need to get the keyhash from the keystore which you used to sign the release apk and add that in the facebook developer site.Marje
This will give you DEBUG hash keyPenumbra
Saved me a lot of time. Still the best. Check the verbose for the keyhash and copy and paste it in the facebook developers page. Don't make the mistake of typing it manually! Also, understand that keyhash changes everytime you uninstall and install the app.Meetly
Thanks. It works me. Previously I tried more time in cmd on Windows 11.Odontoblast
E
262

If you are using Google Play App signing:

Open the App signing section in Google Play Console, and get the SHA-1 hash under App signing certificate. Then convert it to Base64, for example with this tool: Hexadecimal -> base64 string decoder

Console screenshot

Convert to Base64 screenshot

Examinee answered 27/6, 2017 at 14:6 Comment(4)
Thank you! It works! You can also use terminal command for it: echo YOUR_SHA1_CERTIFICATE_COPIED_FROM_GOOGLE_PLAY | sed s/\://g | xxd -r -p | base64Rustle
If after a while you want to find out what all the keys to those hashes are, this reverses it for me: echo "hash_from_facebook" | base64 -D | xxd -p | awk '{print toupper($0)}' | sed 's/../&:/g;s/:$//'Loy
Shall I need to add release key hash or debug hash in the facebook developer account.Allomorphism
Thank you so much. After 2 days of searching for a solution. This is the best answer I found't.Conflation
A
141

If you are facing this problem then put this key into your developer.facebook.com:

Enter image description here

Then make sure your app is live on developer.facebook.com.

This green circle is indicating the app is live:

Enter image description here

If it is not then follow these two steps for make your app live:

Step 1 Go to your application→settingadd Contact Email and apply Save Changes.

Step 2 Go to the App Review option and make sure this toggle is Yes. I added a screenshot:

Enter image description here

Note: If you want to copy the hashkey, check the BlueServiceQueue in LogCat.

Armbrecht answered 23/1, 2016 at 8:41 Comment(19)
Is there an easy way to copy that hash from the phone?Balaam
@DanielShatz it appears in logcat. I found out only after I copied it letter by letter.Estonian
@DanielShatz Look for tag BlueServiceQueue in logcatEstonian
i just enter the keys and it works for me thank you so muchJarman
Welcome @innocentArmbrecht
Is the key will get change if the same apk is install in different device?Please let me know already done the copying of the key char by charBowyer
@Bowyer No i think key will be the same for all mobile what problem you are facing? tell me so i can help.Armbrecht
@ArpitPatel Thanks for solution It works but I want to know why Facebook showing this hash key error on some devices while the release hash key is correct and what would be the correct solution for this which resolve this issue permanently for future applicationsAcromegaly
This answer worked for me. After some attempts of typing hash manually it gave me same error, the problem was, I typed capital i "I" instead of lower case L "l". Took me some time to realise this.Collectivism
Hi, I have release apk and installed in multiple devices. When I try to login into my application it show's invalid hash key error. I have added that hask key in to my face book developer account it's working fine but when I try to login in my app using fb account in another device again shows invalid hash key error. How can we resolved this issue.Esme
Check your app has green circle in Facebook developer site. If not then You need to live that app in your Facebook developer site.Armbrecht
bad solution... :(Nyaya
@Osgux Can you tell me what is wrong with my answer and can you tell me what is the good solution for that?Armbrecht
This is working but Im wondering from where FB get this hash key ? No one wonders ? The error was displaying the good working hash key, but even with all commands, or getting sha1 to base64 from google app signing gave me the key that FB shown in the error ... Thanks for the trick anywayTortilla
it works but why is that happening. what if it happens for live users?Dentilingual
where must I put that cash key. Why nobody asks that? there is no field saying about hash key in the developer.facebook.comIfill
I have a doubt. It seems that the hash key keeps on changing. If you're using a multiple device to login with facebook, the error will appear but not happening all the time.Dympha
at first i though it will be differ from each phone but. no... just copy the exact hash... for live developmentDarladarlan
Which key needs to be added in facebook? Does this is release or debug keyAllomorphism
B
102

I got the same problem. I was sure that it was due to very small fault and yes it was!

I found the solution:

When generating the debug hash key in my computer, I entered the password of my system. But the password should be the following -

Enter keystore password: "android". This was the only problem in my case.

----- For generating Debug key hash, use this command -

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

Enter keystore password: 'android'

----- To Generate Release key hash, use this command -

keytool -exportcert -alias "alias of keystore" -keystore "Your path to the keystore when signing app" | openssl sha1 -binary | openssl base64

Provide your keystore password after executing this command.

Beograd answered 4/2, 2016 at 9:6 Comment(10)
using "android" as the password works for me. this is puzzling.Flawed
use this "android" as a password when generating hash key.Beograd
android is the password for debug version, probably will not work in release.Wallsend
yes, In release version you have to put your keystore passsword @Beto CaldasBeograd
on windows machine, ensure that path variable is properly set for openssl\bin and java..\bin folders. Also set HOMEPATH variable to be able to use commands from facebook.Cowberry
At least on mac I had to install the Java JDK to get this to work. Otherwise the above debug command still generates a hash, but the hash doesn't work and you won't get prompted for a password. With JDK installed this worked like a charm.Cuyp
install openssl @KonstantinKonopkoBeograd
Doesnt work anymore. Have tried multiple times with the android password.. fb still complainsInterpretation
As a comment to this solution - What is important is that you need to have the correct path for: ~/.android/debug.keystore - debug.keystore should be a file that you have in your project. Running command above it won't tell you that path is wrong (your generated key will be wrong and not the same as in the error you get). That was the problem in my case.Gaillard
magically worked for me, thanks!Tops
S
22

I experienced the same problem. I made a short research on the possible reasons for this strange behavior and I found the following:

  • During the first execution of a new Facebook app, it will allow connection/login even if you don't specify any key hashes.

  • For me, the tutorial which Facebook provided didn't generate the correct key hash, because it was giving the wrong configuration. When executing:

    keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl
    base64
    

make sure you check all properties - the HOMEPATH, the existence of the keystore, etc. Maybe you also have to provide password.

  • What generated the proper configuration was the solution suggested by @Mahendran.

  • Also, if you see the error originally posted (https://i.stack.imgur.com/58q3v.png), most probably the key hash you see on the screen is your real one. If nothing else works, try inputting it in Facebook.

I got all those results with: Windows 7 64-bit edition, Android Studio 1.2.2, JDK 7.

Shelly answered 12/7, 2015 at 10:17 Comment(2)
linux version: ` keytool -exportcert -alias androiddebugkey -keystore $HOME/.android/debug.keystore | openssl sha1 -binary | openssl base64`Alexandria
Just input whats shown by facebook on device screen, that should work. Thanks for the note @MartinLyssa
A
19

This is how I solved this problem:

First you have to get the SHA-1 value. For that there are two ways.

To get the SHA-1 value in Android Studio.

  1. Click Gradle
  2. Click Signing Report
  3. Copy the SHA-1 value

OR

To get the SHA-1 value from the keystore file.

keytool -list -v -keystore keystore_file_name.jks -alias key0

Copy the SHA-1 value to your clipboard like this:

CD:A1:EA:A3:5C:5C:68:FB:FA:0A:6B:E5:5A:72:64:DD:26:8D:44:84

And open Hexadecimal -> Base64 string decoder to convert your SHA-1 value to Base64.

This is what Facebook requires.

Get the generated hash " ********************= " and copy the key hash to the Facebook app.

Archaic answered 21/2, 2019 at 13:12 Comment(2)
this answer works for meAdonic
worked for me... you should get long life :) @Sajid ZebMormon
C
15

According Facebook Login for Android, you must provide the key hash value. In order to obtain it, you will need the key used to sign your application.

keytool \
    -exportcert \
    -alias YourKeyAlias \
    -storepass YourStoreKeyPassword \
    -keystore PathToYourKeyStoreFile | openssl sha1 -binary | openssl base64
Cittern answered 24/5, 2014 at 18:10 Comment(4)
just want to add a comment, use your production keystore.Weekender
@Weekender Actually you should use all your keys because otherwise you won't be able to test Facbeook Login in debug environment.Satisfactory
@Pius, yes, I actually use both keys. I should have stated it clearly.Weekender
I get an error for this command (No Java runtime present, requesting install.) but still get a key too, however is invalid and i just copy paste the one from logcat that tells me is not recognised.Severin
C
9

Even though this question has been answered in alot of helpful ways I just wanted to add that when I followed Rafal Maleks answer (using the hash keys on Google Play Console) I was NOT able to use the App Signing SHA1 key, still got the generic error from Facebook. Instead I needed to use the SHA-1 certificate fingerprint from the Upload Certificate part (just below the App Signing part on Google Play Console). Same process otherwise;

  1. Copy the SHA-1 certificate fingerprint from Upload Certificate section in Google Play Console

  2. Convert the SHA-1 using: http://tomeko.net/online_tools/hex_to_base64.php and copy the output (base64)

  3. Paste it into the Key Hashes input on developer.facebook.com and save changes.

Hopefully this answer isn't to redundant and will help someone that can't get it to work with the App Signing certificate.

Now Facebook login works in my app both in debug and release mode.

Contrariety answered 22/11, 2019 at 10:17 Comment(0)
S
8

I tried all of the previous answers and nothing helped my case with my clients!

Then my client remembered he had the Facebook App installed on his device. After he removed it. the login worked perfectly.

The hashkey had been changed, and I've replaced the old hash keys at Facebook Developers Console with the key from the error (as suggested above), and it works!

The Facebook App itself might be the issue, so you better figure this out on a device with the Facebook app installed and on a device with the Facebook app not installed and handle both cases...

Spessartite answered 24/4, 2017 at 16:30 Comment(2)
Yes same here I got this error after installing facebook app on device. So currently I put 2 hash key on Facebook dev settings.Noelnoelani
I have very similar situation to yours. The thing that helped me is go to your FB page - Settings - Apps - Remove the app from the list. Change hash key and reinstall fb app and your app. And now it works...Americanize
D
8

You must create two key hashes, one for Debug and one for Release.

For the Debug key hash:

On OS X, run:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

On Windows, run:

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl
base64

Debug key hashes source

For the Release key hash:

On OS X, run (replace what is between <> with your values):

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

On Windows, use (replace what is between <> with your values):

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

Release key hashes source

Disaffirm answered 17/9, 2017 at 14:15 Comment(2)
I get an error for this command (No Java runtime present, requesting install.) but still get a key too, however is invalid and to make it work i just copy paste the one from logcatSeverin
Maybe you havent set the PATH of your java and keytool in the command line ? @CristiBăluțăDisaffirm
H
4

The following code will give you your hash for Facebook, but you have to follow these steps in order to get the release candidate hash.

  1. Copy and paste this code in your main activity

    try {
        PackageInfo info = getPackageManager().getPackageInfo(
                               "com.example.packagename",
                               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) {
    }
    catch (NoSuchAlgorithmException e) {
    }
    
  2. Generate a signed APK file.

  3. Connect your phone to a laptop and make sure it stays connected.
  4. Install and run the APK file in your phone by manually moving the release APK to your phone.
  5. Now look at Android LogCat (use filter KeyHash:). You should see your release hash key for Facebook. Simply copy and paste it in your https://developers.facebook.com/apps. It's under settings.
  6. Now you can test the app it should work perfectly well.
Hereat answered 8/5, 2017 at 19:27 Comment(2)
note the code only works if you generate signed apk. otherwise it will only give you debug apk hash which is useless for released apkHereat
Hi, when I gave generated hashkey to the facebook app it works fine but when try to run in another device it's again showing 'INVALID HASH KEY' how can I set hash key for the face book contain for work in all devices.Esme
D
3

I was having the same problem. First log in, just fine, but then, an invalid key hash.

The Facebook SDK for Unity gets the wrong key hash. It gets the key from "C:\Users\"your user".android\debug.keystore" and, in a perfect world, it should get it from the keystore you created in your project. That's why it is telling you that the key hash is not registered.

As suggested by Madi, you can follow the steps on this link to find the right key. Just make sure to point them to the keystore inside your project. Otherwise you won't get the right key.

Demetra answered 15/11, 2015 at 18:43 Comment(0)
S
3

If you are typing the keyhash manually (for example from mobile to the Facebook Dashboard), make sure to differentiate between small L and capital I.

Swarey answered 13/10, 2018 at 8:51 Comment(0)
S
2

After a long research, we found a solution.

We had set permissions as:

loginButton.setReadPermissions(public_profile email);

This worked for the first time, but when we re-logged in to Facebook, it gave the Invalid Hash Error.

The simple solution was to change the above line to:

loginButton.setReadPermissions(Arrays.asList("public_profile", "email"));

And it worked like a bliss!

Facebook should return the correct exception instead of the misleading invalid hash key error.

Swec answered 2/6, 2016 at 12:37 Comment(1)
I have same problem.I tried your solution but still can't solve my problem @SwecForay
R
2

After so many trials I stumbled on a solution to this. I generated and added both debug and release keys to the Facebook developer console and still got the error.

The only solution that worked for me was is to uninstall the OpenSSL program from Google and download from Win32/Win64 OpenSSL Installer for Windows

It really works like magic.

Rebate answered 15/2, 2018 at 5:48 Comment(0)
A
2
try {
    PackageInfo info = getPackageManager().getPackageInfo(
                           "www.icognix.infomedia",
                           PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("YourKeyHash: ", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        Log.d("YourKeyHash: ", Base64.encodeToString(md.digest(), Base64.DEFAULT));
    }
}
catch (PackageManager.NameNotFoundException e) {
}
catch (NoSuchAlgorithmException e) {
}
Albright answered 10/3, 2019 at 17:9 Comment(0)
D
1

Paste the following code into your OnCreate method:

try {
    PackageInfo info = getPackageManager().getPackageInfo(
                           "com.example.packagename",
                           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();
}

Just modify the package name. Then go to your LogCat file and select Debug search here. Then you will find the hash key. Now copy this hash key and then go to the developer.facebook.app_id site, edit your hash key, and press Save. Now run your Android project again. I think issue will be resolved.

Dipietro answered 26/1, 2015 at 10:9 Comment(1)
repeating the other guyWallsend
K
1

This may help someone with the same problem.

  1. Generate the key hash using the below code

    keytool -exportcert -alias <your_keystore> alias -keystore <your_keystore_file> | openssl sha1 -binary | openssl base64
    

    How to use keytool

  2. Paste it in required field in Facebook developer

  3. In Android Studio, menu FileProject Structure

    Enter image description here

    Add signing parameters.

  4. Select flavors

    Enter image description here

    Select the signing configuration we created.

  5. Select build type

    Enter image description here

  6. Select build variant and build it

    Enter image description here

Kannan answered 14/6, 2016 at 15:30 Comment(0)
H
1

I had the same problem when I was debugging my app. I've rewrote the hash that you have crossed out in the attached image (the one that Facebook says is invalid) and added it in the Facebook's developers console to key hashes. Just be careful of typos.

This solution is more like an easy workaround than a proper solution.

Heterography answered 24/6, 2017 at 19:17 Comment(0)
R
1

I saw many people giving difficult answers, the to the point answer through which I fixed my issue is just go to the project/android folder/app using terminal, this is where your debug.keystore file is

keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64

copy and paste this command, replace the alias and used the same password which is in your project/android/app/build.gradle

debug {
  storeFile file('debug.keystore')  
  storePassword 'android'
  keyAlias 'androiddebugkey'      <---- alias
  keyPassword 'android'           <---- password
}
Repossess answered 31/10, 2022 at 19:38 Comment(0)
B
0

What Facebook used is not the default password and alias for debug. You need to change it following and it will work.

/usr/lib/jvm/jdk1.8.0_66/bin/keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

If you have not changed anything with the default password it should be "android".

You can also configure it in the build.gradle file. But the same alias password should be used for generating the hash:

android {
    signingConfigs {
        release {
            storeFile file("~/.android/debug.keystore")
            storePassword "android"
            keyAlias "androiddebugkey"
            keyPassword "android"
        }
    }
}
Beginner answered 20/7, 2016 at 14:37 Comment(0)
S
0

Here are a lot of right answers. Just one thing:

Paste the received hash into ApplicationSettingsMain, not via the fast start tutorial.

Swale answered 23/6, 2017 at 14:23 Comment(0)
U
0

I had the same problem.

Make sure that you build the APK file with the same device that generated the hashkey which is stored on in the Facebook developers section.

Unriddle answered 13/1, 2019 at 20:1 Comment(0)
H
0

I fixed this by adding the following into MainApplication.onCreate:

try {
    PackageInfo info = getPackageManager().getPackageInfo(
                           "com.genolingo.genolingo",
                           PackageManager.GET_SIGNATURES);

    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        String hash = Base64.encodeToString(md.digest(), Base64.DEFAULT);
        KeyHash.addKeyHash(hash);
    }
}
catch (PackageManager.NameNotFoundException e) {
    Log.e("PackageInfoError:", "NameNotFoundException");
}
catch (NoSuchAlgorithmException e) {
    Log.e("PackageInfoError:", "NoSuchAlgorithmException");
}

I then uploaded this to the Google developer console and then downloaded the derived APK which, for whatever reason, has a totally different key hash.

I then used LogCat to determine the new key hash and added it Facebook as other users have outlined.

Horrendous answered 13/2, 2019 at 10:46 Comment(0)
C
0

If you're generating release key hashes, make sure you enter the actual password of your keystore and not "android".

This was my issue. Debug release was working, but the release APK was not.

Calysta answered 2/10, 2019 at 9:44 Comment(0)
A
0

I also had the same problem. What solved the problem is adding the hash on the screen to my app.

Au answered 17/5, 2022 at 15:41 Comment(0)
O
0

I am sorry to say but nothing actually worked for me. Finally what helped me is get the upload SHA-1 certificate fingerprint from google play console and convert it to base64 and adding it to facebook. If anyone need help please comment

Orate answered 28/6, 2022 at 5:46 Comment(0)
A
0

I solved this problem by changing the phat of the debug.keystore, the correct phat must be the phat of your Android project file. Like this:

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\yourUser\Documents\other\yourProjectName\android\app\debug.keystore" | "C:\openssl\openssl-3\x64\bin\openssl" sha1 -binary | "C:\openssl\openssl-3\x64\bin\openssl" base64

if you don't know how to get the phat of openSSL I recommend you this video on youtube: https://youtu.be/aZlkW3Evlx4

Arrhythmia answered 8/2, 2023 at 18:3 Comment(0)
F
-1

Use the below code in the onCreate() method of your activity:

try {
    PackageInfo info = getPackageManager().getPackageInfo(
                           "your application package name",
                           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) {
}
catch (NoSuchAlgorithmException e) {
}

Run this code. This will generate the hash key. Copy this KeyHash in the Facebook application setting, and save changes. Then log into your application. This will work perfectly in the future too.

Flora answered 27/9, 2015 at 17:39 Comment(1)
repeating the other guyWallsend
N
-1

To get the SHA1 key hash for your Facebook Android app, you will need to first generate the SHA1 value from your keystore file. You can do this by running the following command in a terminal:

keytool -list -v -keystore keystore_file_name.jks -alias key0

This will output the SHA1 value to the console. You can then copy the SHA1 value to your clipboard.

Next, you will need to convert the SHA1 value to base64. You can do this by visiting the following website:

http://tomeko.net/online_tools/hex_to_base64.php

Paste the SHA1 value into the input field and click on the "Convert" button. This will generate the base64-encoded SHA1 value.

Finally, you will need to copy the base64-encoded SHA1 value to your Facebook app. You can do this by going to the "Settings" page in your Facebook app and adding the key hash to the "Key Hashes" field.

Once you have added the key hash, your Facebook app will be able to communicate with the Facebook servers.

Naarah answered 4/8, 2023 at 8:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.