Phonegap build - Facebook connect plugin - Invalid android_key parameter error

I run the sample code (see below) through the phonegap assembly to create the android apk.

https://github.com/phonegap-build/FacebookConnect/blob/master/example/Simple/index.html

When I try to login to facebook through the application on the Android device (with the facebook application installed), I get this error:

Invalid android_key parameter J4INwYsuTyQ_LJc1d3WZ2HReg7M does not match the allowed android key. Configure application key hashes on http://developers.facebook.com/apps/ 'application id

I copied this key to the key hashes section of my Android app settings, but it still throws the same error when I try to log in using the app.

How can I get this application to log in to facebook successfully?

OR: How can I enable the Android application to log in to facebook via telephone?

Here is what I did:

  • In the settings of my facebook application:

    • Set the “Package Name” to the “widget id” found in my phonegap config.xml.
    • Set the 'Class Name' for the package name with .ProjectActivity added to it.
    • Enabled "Single Sign on" and disabled "Deep linking".
    • Make the application open to the public (through the "Status and Overview" section.
  • In my phonegap config.xml (found in the / www directory in the phonegap project):

    • Entered APP_ID as an identifier found in my facebook toolbar
    • Entered by APP_NAME as the "namespace" found in the settings of my facebook application.
  • In the settings of the application for creating mobile phones:

0
source share
2 answers

I successfully made an application that can login to facebook using the phonegap-facebook plugin and creating a local cordova / phonegap project.

I made a new cordova project and added the android platform for this project, following the instructions here: http://docs.phonegap.com/en/3.4.0/guide_overview_index.md.html#Overview

In doing so, I found that I had made my previous project using the old version of Cordova (3.1) unnamed and that I did not install the cordova command line interface. Perhaps there were other problems with the way I made my first project.

Then I added the phonegap-facebook plug-in: https://github.com/phonegap/phonegap-facebook-plugin with this command (from my project location):

cordova plugin add https://github.com/phonegap/phonegap-facebook-plugin.git --variable APP_ID="xxxxxxxxxxxxx" --variable APP_NAME="xxxxxxxx" 

(replacing the APP_ID value with my facebook app id and the APP_NAME value in the application namespace).

Then I replaced my index.html with the sample index file that was found on the gmailub page phonegap-facebook-gigub + / blob / master / example / Simple / index.html (replacing the app_id value with my application identifier).

Then I launched the application directly on my Android device using:

  cordova run android 

In this application, I can use the interface presented in this example to log in, send walls to my own or friends, etc. Using this new project (with an updated version of the cord), I can use the phonegap build function but I have not tried it yet.

Thanks to Dato Mohammad Nurdin for the offer to use this plugin.

0
source

I think you should use the facebook phonegap plugin as your authentication.

Download and install cordova into your project.

https://github.com/phonegap/phonegap-facebook-plugin

Use this command to install it.

 cordova plugin add https://github.com/phonegap/phonegap-facebook-plugin.git --variable APP_ID="xxxxxxxxxxxxx" --variable APP_NAME="xxxxxxxx" 

Then set up your facebook app here:

http://developers.facebook.com/apps/

Then make sure you have this script in your project.

 cdv-plugin-fb-connect.js facebook-js-sdk.js 

After that, paste this code into your main script

 if ((typeof cordova == 'undefined') && (typeof Cordova == 'undefined')) alert('Cordova variable does not exist. Check that you have included cordova.js correctly'); if (typeof CDV == 'undefined') alert('CDV variable does not exist. Check that you have included cdv-plugin-fb-connect.js correctly'); if (typeof FB == 'undefined') alert('FB variable does not exist. Check that you have included the Facebook JS SDK file.'); FB.Event.subscribe('auth.login', function(response) { //alert('auth.login event'); }); FB.Event.subscribe('auth.logout', function(response) { //alert('auth.logout event'); }); FB.Event.subscribe('auth.sessionChange', function(response) { //alert('auth.sessionChange event'); }); FB.Event.subscribe('auth.statusChange', function(response) { //alert('auth.statusChange event'); }); function getSession() { alert("session: " + JSON.stringify(FB.getSession())); } function getLoginStatus() { FB.getLoginStatus(function(response) { if (response.status == 'connected') { alert('logged in'); } else { alert('not logged in'); } }); } var friendIDs = []; var fdata; function logout() { FB.logout(function(response) { alert('logged out'); window.location.replace("#login"); }); } function login() { FB.login( function(response) { if (response.authResponse) { alert('logged in'); FB.api('/me', function(me) { if (me.id) { localStorage.id = me.id; localStorage.email = me.email; localStorage.name = me.name; window.location.replace("#home"); } else { alert('No Internet Connection. Click OK to exit app'); navigator.app.exitApp(); } }); } else { alert('not logged in'); } }, { scope: "email" }); } document.addEventListener('deviceready', function() { try { //alert('Device is ready! Make sure you set your app_id below this alert.'); FB.init({ appId: "appid", nativeInterface: CDV.FB, useCachedDialogs: false }); document.getElementById('data').innerHTML = ""; } catch (e) { alert(e); } }, false); 

use login() to log in. Enjoy !!

0
source

Source: https://habr.com/ru/post/977325/


All Articles