问题
I have a strange problem using the facebook plugin with phonegap build. It sounds like a certificate problem but I can't figure it out.
I tried the sample code found here : github.com/amirudin/pgb-fbconnect
I followed instructions in the readme.md file.
When I first start the android app and when I click on "login" button, everything works fine and I can connect myself to the facebook app.
Now, I hit the logout button. Ok again, it works.
But if I hit the login button again, I have a facebook error message : "invalid android_key_parameter. The key xxxxxxxxxxxxxx does not match any allowed key."
But the xxxxxx key in the message does not correspond to the key I've put in the facebook app config panel.
I have a little video of my problem here : Dropbox video
I don't understand why it works fine during the first login and fail during the second one .... It seems that the second time, the signature change.
Help!!
I created a github repo if someone want to test it. You just have to change the APP_NAME and APP_ID in the config.xml and the APP_ID in index.html
It's very frustrating to have something which "almost" works.
Did you succeed in reproducing my bug/behavior ? (login + logout + login = fail)
回答1:
The problem you are facing because of you are not using right keystore file, Signed key, and key algorithm. You will need to generate a hash of your Android key(s) and submit those to the Developers page on Facebook.
If you are generating this hash on Windows (specifically 64 bit versions), please use version 0.9.8e or 0.9.8d of OpenSSL for Windows and not 0.9.8k.
Once you download openssl, open the command prompt (cmd.exe) as an Administrator, then run the following command:
keytool -genkey -v -keystore [keystore_name].keystore -alias [alias_name] -keyalg RSA -keysize 2048 -validity 10000
Please note the alias_name
, and keep all passwords andriod
Now, go to your phonegap account >> edit account >> Click on signing keys tab >> Click 'add a key...' and supply the following info:
Title - anything
Alias - alias_name that you have given while generating the keystore file.
Then, create a new hash key using the keystore file that you generated and then update that hash key in your facebook app.
Use below command to generate hash key.
keytool -exportcert -alias [alias_name] -keystore [keystore_filename.keystore] | openssl sha1 -binary | openssl base64
That should be it!
来源:https://stackoverflow.com/questions/18111436/phonegap-build-facebook-connect-plugin-android