2

I have successfully integrated Nativescript firebase plugin to enable facebook authentication. My FB login call looks like this:

firebase.login({
    type: firebase.LoginType.FACEBOOK,
    // Optional
    facebookOptions: {
      // defaults to ['public_profile', 'email']
      scope: ['public_profile', 'email']
    }
  }).then(
      function (result) {
        JSON.stringify(result);
      },
      function (errorMessage) {
        console.log(errorMessage);
      }
  );

Login fails with error "Error while trying to login with Fb SERVER_ERROR: [code] 1349195 [message]: The key hash does not match any stored key hashes" which is evident because I haven't added Keyhash in Facebook app.

I was expecting a key hash value in the error message according to the documentation so that I can add it in Facebook app.

I think the error message would have key hash only when the app is signed

Issue

  • I have already spent hours without any luck figuring out how to sign the app in debug mode. I am running the app using the command 'tns debug android'
  • I know it is possible to sign the app using 'tns run android' but it won't let me debug the app.

I think I am missing something tiny here - Any help would be appreciated.

shobhit vaish
  • 951
  • 8
  • 22

3 Answers3

0

As mentioned in the {N} docs, the debug builds are signed by the debug keystore created and managed by Android itself.

If you refer the official Android docs, you will know where these certificates are located.

  • ~/.android/ on OS X and Linux
  • C:\Documents and Settings\user\.android\ on Windows XP
  • C:\Users\user\.android\ on Windows Vista and Windows 7, 8, and 10
Manoj
  • 21,753
  • 3
  • 20
  • 41
  • Alright, according to the docs debug builds are signed automatically. So that means error message should also have printed the key hash, right? I have also tried generating key hash manually `keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%.android\debug.keystore | openssl sha1 -binary | openssl base64` but the output looks invalid because it isn't 28 chars long. – shobhit vaish May 04 '19 at 10:37
  • I'm on Mac OS (10.14.4), it works perfectly fine for me, returns the 28 chars hash key. – Manoj May 04 '19 at 13:56
0

Finally, I solved it using this. It turned out that it is important to keep extracted SSL folder in C drive.

shobhit vaish
  • 951
  • 8
  • 22
0

Just using NativeScript, You can find your facebook key hash by running logs with command tns device log or tns device log --device <Device ID>, if multiple devices are connected. Device ID is the device index or identifier as listed by the tns device command (source: https://docs.nativescript.org/tooling/docs-cli/device/device-log).

The facebook key hash is now visible in the logs in format fb4a.BlueServiceQueue: X.2nk: [code] 404 [message]: Key hash <THIS_IS_YOUR_HASH> does not match any stored key hashes. Just Ctrl+F key hash or similar in the terminal to find this log.

Last, paste the hash to Facebook developer console where you have created your Android app (Basic tab) next to Google Play Package Name field (nativescript id from your package.json) field and Class name field (com.tns.NativeScriptActivity). You don't need to have live app to try the Firebase Facebook auth, it works on development mode too.

enter image description here

Zuzze
  • 241
  • 2
  • 6