I'm having some trouble connecting to the Linkedin API.
I'm following this https://developer.linkedin.com/docs/android-sdk and this https://developer.linkedin.com/docs/android-sdk-auth, yet I'm getting this error code:
{
"errorCode": "INVALID_REQUEST",
"errorMessage": "either bundle id or package name \/ hash are invalid, unknown, malformed"
}
My implementation so far is pretty simple:
public void shareOnLinkedin() {
AuthListener authListener = new AuthListener() {
@Override
public void onAuthSuccess() {
Log.d(TAG, "Success");
}
@Override
public void onAuthError(LIAuthError error) {
Log.d(TAG, error.toString());
}
};
LISessionManager
.getInstance(getApplicationContext())
.init(ColectionDetailActivity.this, buildScope(), authListener, true);
}
private static Scope buildScope() {
return Scope.build(Scope.R_BASICPROFILE, Scope.W_SHARE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
...
try {
LISessionManager.getInstance(getApplicationContext())
.onActivityResult(this, requestCode, resultCode, data);
} catch (Exception e) {
e.printStackTrace();
}
}
Make sure you've added all you package hashes correctly in your LinkedIn Developer Console.
Generating a debug key hash value
It's under Mobile and would look like this,
App's Package that will be using the LinkedIn SDK: com.mypackage.app
Generated package hash: /i17lYLZpSffk1wdD+KzlRJroZU=
I had the same issue, after implementing fb login i started implementing LinkedIn Login and added the same hash which i got it for fb login and it didn't work.
I did the following in order to fix the issue.
For Release Hash:
Run this command on your release apk to print all the certificate
keytool -list -printcert -jarfile <your apk path>
Copy the SHA1 value Go to http://tomeko.net/online_tools/hex_to_base64.php and convert your SHA1 hex value to Base64
added hash in linked in dashboard and its started working.
Note: if anyone has idea why regular keystore method fails and why this one works please let me know.
This is for Debug Hash:
The above method will work for the debug apk too. but this is how i got the hash for debug apk and it's different from given keystore command.
private void getTokenInfo() {
try {
PackageInfo info = getPackageManager().getPackageInfo(
"your package name here",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Logger.d("packageName", info.packageName);
Logger.d("hash", Base64.encodeToString(md.digest(), Base64.NO_WRAP));
}
} catch (PackageManager.NameNotFoundException e) {
Logger.e(e);
} catch (NoSuchAlgorithmException e) {
Logger.e(e);
}
}
This is working for me and i yet to understand whats happening here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With