签名APK中的Linkedin登录错误(Android) [英] Linkedin Login Error in Signed APK(Android)
问题描述
我使用以下代码在android中使用LinkedIn登录
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
并将哈希密钥添加到LinkedIn开发人员帐户,并运行显示错误的发行版apk文件
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"
推荐答案
由于只有签名的APK才出现此问题,因此您配置了错误的发布密钥哈希值.
Since only signed APKs have this problem, you have configured an incorrect release key hash value.
尝试检查在 LinkedIn应用程序的配置:
生成发布密钥哈希
要生成释放密钥哈希,请使用以下命令:
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
配置值
您可以使用以下逗号分隔的格式在LinkedIn应用程序的配置中提供一个或多个值:
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
希望这会有所帮助.
这篇关于签名APK中的Linkedin登录错误(Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!