问题
I use LinkedIn Login in android with the following code
private void linkedInLogin() {
/*isLogin();*/
System.out.println( "insidelogin" + "linkedin" );
LISessionManager.getInstance( getApplicationContext() ).init( this, buildScope(), new AuthListener() {
@Override
public void onAuthSuccess() {
System.out.println( "sucesslogin" + "linkedin" );
accessLinkedInData();
}
@Override
public void onAuthError(LIAuthError error) {
// Handle authentication errors
System.out.println( "login_error" + error );
}
}, true );
}
private void accessLinkedInData() {
String url = "https://api.linkedin.com/v1/people/~:(id,first-name,last-name,email-address,picture-url)?format=json";
//String url = "https://api.linkedin.com/v1/people/~?format=json";
APIHelper apiHelper = APIHelper.getInstance( getApplicationContext() );
apiHelper.getRequest( this, url, new ApiListener() {
@Override
public void onApiSuccess(ApiResponse apiResponse) {
//System.out.println( "apiResponse" + apiResponse.getResponseDataAsString() );
JSONObject linkedinResponse = apiResponse.getResponseDataAsJson();
firstName = linkedinResponse.optString( "firstName" );
lastName = linkedinResponse.optString( "lastName" );
emailAddress = linkedinResponse.optString( "emailAddress" );
mLinkedInID = linkedinResponse.optString( "id" );
if (linkedinResponse.has( "pictureUrl" )) {
profilePicUrl = linkedinResponse.optString( "pictureUrl" );// profile picture for uploading sometimes it get null
}else {
profilePicUrl = "";
}
isSocialLogin = true;
socialLogin();
}
@Override
public void onApiError(LIApiError liApiError) {
// Error making GET request!
}
} );
}
private static Scope buildScope() {
return Scope.build( Scope.R_BASICPROFILE, Scope.R_EMAILADDRESS );
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Add this line to your existing onActivityResult() method
LISessionManager.getInstance( getApplicationContext() ).onActivityResult( this, requestCode, resultCode, data );
}
and generate a hash key using this code in a development mode
private void computeHash() {
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo( "com.cap.connectingjobs", PackageManager.GET_SIGNATURES );
for (Signature signature : packageInfo.signatures) {
MessageDigest messageDigest = MessageDigest.getInstance( "SHA" );
messageDigest.update( signature.toByteArray() );
Log.d( "KeyHash:", Base64.encodeToString( messageDigest.digest(), Base64.DEFAULT ) );
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
After all, this works fine but when I create hash key for final release using
keytool -exportcert -keystore YOUR_RELEASE_KEY_PATH -alias YOUR_RELEASE_KEY_ALIAS | openssl sha1 -binary | openssl base64
and added the hash key to the LinkedIn developer account and run the release apk file it shows an error
"errorMessage": "either bundle id or package name \/ hash are invalid, unknown, malformed", "errorCode": "UNKNOWN_ERROR"
回答1:
Since only signed APKs have this problem, you have configured an incorrect release key hash value.
Try checking the release key hash value of the keystore correctly listed in the "android package name and hash" LinkedIn application configuration correctly listed in your LinkedIn application's configuration:
Generate a release key hash
To generate a release key hash, use the following command:
keytool -exportcert -keystore YOUR_RELEASE_KEY_PATH -alias YOUR_RELEASE_KEY_ALIAS | openssl sha1 -binary | openssl base64
Configuration value
You can provide one or more values in the configuration of your LinkedIn application using the following comma-separated format:
Android.Package.Name,Key-Hash-Value
Hope this helps.
回答2:
Go to Play store and dowload the MODIFIED version of the apk (Your App -> Versions -> Manage -> Download symbol near apk icon).
Follow the instructions here: https://ibby.ca/extract-key-hash-apk-file/. Generate another key hash, convert the SHA1 into Base64 value in http://tomeko.net/online_tools/hex_to_base64.php and register it in Linkedin as your release hash.
来源:https://stackoverflow.com/questions/51203475/linkedin-login-error-in-signed-apkandroid