Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic Facebook Api invalid key hash

I can't get my app to allow Facebook login. Everytime the users tries to login to Facebook and authenticate my app with their FB, it gives me this error:

Invalid key hash. They key hash xxxxxxxxxx= does not match any stored key hashes. configure your app key hashes at http://developers.facebook.com/apps/xxxxxxxx

I've already tried creating a new key hash through the OpenSSL tool like so:

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

Doing this gives me a key hash, which I then add into the 'Key Hashes' list on the developer page for the app. I then use ionic to rebuild the app, and when I run it on my android phone it gives the same error. There is another version of the app that was built on another computer, and a different hash key was used, and that worked perfectly, but the hash key from this computer doesn't seem to want to work. Any help would be great

like image 675
Iqbal Khan Avatar asked Nov 24 '15 23:11

Iqbal Khan


People also ask

How do I get a key hash on Facebook?

Go to the Facebook Developer site. Log into Facebook and, using the dropdown menu in the top-right, go to Developer Settings: In your developer settings, select Sample App from the menu, and add and save your key hash into your profile: You can add multiple key hashes if you develop with multiple machines.


3 Answers

  • On Windows: keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
  • On Mac: keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

The password is android.

Also see the Ionic docs for more info.

like image 95
janekkkk Avatar answered Sep 19 '22 00:09

janekkkk


Following steps solved my problem

  1. Go to facebook account inside settings > Apps and Websites > Logged in with Facebook > Active > click on ur app > And Remove App

  2. After doing that try to login now and this time you will get facebook error code 1349195 : something like go to facebook docs/android page and do the setting

  3. Now run the command from yours teminal

keytool -list -printcert -jarfile yourapkname.apk

Copy the SHA1 value and convert that into base64 and paste that base64 value into you facebook account and then try login.

To convert sha1 to base64, you can use http://tomeko.net/online_tools/hex_to_base64.php

like image 35
puneet Avatar answered Sep 22 '22 00:09

puneet


He had the same problem. My solution:

On ubuntu:

keytool -exportcert -alias androiddebugkey -keystore /home/"username"/.android/debug.keystore | openssl sha1 -binary | openssl base64

(replaces your "username")

Now you need to enter password, Password = android

I hope that helps.

like image 36
Franj Avatar answered Sep 21 '22 00:09

Franj