Android Facebook Integration Error - android

I need a help. I am trying to integrate Facebook to my android app so that the users can log in using Facebook. The app runs perfectly on emulator but giving error on real devices. I am getting
Invalid android_key parameter. The key does not match any allowed key
Can Any one help me out to solve this problem?
Thanks in advance.

Just a shot in the dark.
Developers use to forget indicating the Android hash key in the developer settings of their FB account.

I think your problem is about hash key.
You may forgot to put android key hash in developer settings in your Facebook app. Or you may put a wrong one.

Check the below links that are related to the issue.
App is misconfigured for Facebook login: Android Facebook integration issue
https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/

I think hash key problem ,, use this code to get hash key...
private void getKeyHash() {
try {
PackageInfo info = SplashActivity.this.getPackageManager()
.getPackageInfo(SplashActivity.this.getPackageName(),
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Logger.e("KeyHash:",
Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}

Related

LinkedIn Ingtegration in Android

I am making a demo project where integrating linkedin. In the developer site of linked in added hashkey and package but still getting {
"errorCode": "INVALID_REQUEST",
"errorMessage": "either bundle id or package name / hash are invalid, unknown, malformed"
}
Please note:i have seen many blog and question in the stackoverflow but still unable to resolve. and yes m entering correct package name and hash key.
If you have Generated a debug key hash value.
If you've added all you package hashes correctly in your LinkedIn Developer Console.
And finally you might want to save changes by clicking the blue button labelled "Update".
Test your app again
The problem is most likely your hash key, try generating it using the below code.
Try this code in your MainActivity
try {
PackageInfo info = getPackageManager().getPackageInfo("Package name",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.e("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch(PackageManager.NameNotFoundException| NoSuchAlgorithmException e) {
}

What is a key hash?Why it is needed?Is it unique?Why it is necessary for facebook integration

What is a key-hash, why it is needed and is it unique? Also why it is necessary for facebook integration?
My code to get the HashKey:
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();
}
What is key Hash?
It's a 28 character string that Facebook uses to authenticate interactions between your app and the Facebook.
Why it is Unique?
As already mentioned in comments, It identifies your app in Facebook developer platform.
Why it is needed? Why it is necessary for Facebook Integration?
It is needed to authenticate the exchange of information between your app and the Facebook. Without this, your Facebook integration may not work properly when you release your app to the store. If you run apps that use Facebook Login then you need to add your Android development key hash to your Facebook developer profile.
For integrating your app with facebook API you will need this key. Log KeyHash will give you value which you will have to write in facebook app's setting page.
than only your application with given SHA1 code will able to access facebook api. Or you'll get authorization error. P.S: It will be unique and different for all apps and testing device and even workspace.

Android Facebook Key Hash Stopped Working

I am creating an Android app that will integrate with Facebook. I have been able to successfully generate a Key Hash, and when I run my app to log in, I successfully got to the accept permissions button. I clicked accept and since then, I haven't been able to log back in from the app. I am given the error "(insert the key has i'm using here) does not match any allowed key. Configure your app key hashes at (lists my Facebook developer URL)". Is there any reason why a Key Hash would work and then would just stop? I did not alter any facebook settings and did not alter any application code. I've tried creating a new key hash, but that still didn't work. Any ideas on what this could be, or how to resolve it would be greatly appreciated!
I figured this out. Somehow, the Hash Key just stopped matching what I had inserted on the Facebook side. Using the facebook documentation, I added in code in my onCreate method that told me what the hash key was in my LogCat. I also added in some logging code for my catch exceptions in the event that I was screwing up my package name. This is the code:
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.your.package",
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) {
Log.d("Error1", "NameNotFoundException");
} catch (NoSuchAlgorithmException e) {
Log.d("Error2", "Algorthim");
}
After I added that and ran it, I found the hash key in my log cat, and then just copied that to my Facebook App. Saved it, ran the app again and it worked!

Facebook error : allow key: configure your app key hashes at dev.facebook android [duplicate]

This question already has answers here:
This app has no Android Key hashes configured. - Login with Facebook SDK
(5 answers)
Closed 7 years ago.
When i run my facebook apps i get the following error. allow key. Configure your app key hashes at http://developers.facebook.com/apps/178779105632639 ...
Any idea?
It seems that hashkey you generated is not correct. You can generate app hash key from the following code. Try it
public static void showHashKey(Context context) {
try {
PackageInfo info = context.getPackageManager().getPackageInfo(
"com.example.project", PackageManager.GET_SIGNATURES); //Your package name here
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.v("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
}
1.It will Help you.Working fine link
2.while creating app, in developer site using some keyhash generated by your cmd prompt,use that KeyHash copy and paste
in developer Settings Page keyhash Column.
3.change the Single sign on toggle button-YES
You need to generate a hash key for your application and register that to the FB Developers console where you have created the application. I have written a blog for the same. You can find it out at :
http://www.solutionanalysts.com/blog/android-generate-key-hash-facebook
Hope this helps you.

Implementing facebook in android

Hi i am using new sdks of facebook for publishing.Everything is working fine except that i am unable to login from my android app if already facebook is installed means that if facebook application is n*ot installed on phone* i can sucessfully post data to facebook through my mobile application but if user has installed the facebook app , i cannot post my data.
Kindly help me in this stuff..
Sorry for incorrect English..
Looking at your problem I suggest you look at this.
The crux of the problem is that the keytool on windows messes up the key hash.
Do
"keytool -export ..." instead of "keytool -exportcert ...";
Both generate keys but the second one messes it up.
You can also get the key by putting this in your activity
try {
PackageInfo info = getPackageManager().getPackageInfo("com.yourcompany.client", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("Hash Key:", Base64.encode(md.digest()));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}

Categories

Resources