简体   繁体   English

Linkedin Android SDK - 无法连接到API(INVALID_REQUEST)

[英]Linkedin Android SDK - Unable to connect to API (INVALID_REQUEST)

I'm having some trouble connecting to the Linkedin API. 我在连接到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: 我正在关注这个https://developer.linkedin.com/docs/android-sdk和这个https://developer.linkedin.com/docs/android-sdk-auth ,但我收到此错误代码:

{
"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. 确保您已在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 应用程序包将使用LinkedIn SDK: com.mypackage.app

Generated package hash: /i17lYLZpSffk1wdD+KzlRJroZU= 生成的包哈希: /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. 我有同样的问题,在实施fb登录后,我开始实施LinkedIn登录并添加了相同的哈希,我得到它用于fb登录,但它不起作用。

I did the following in order to fix the issue. 我做了以下以解决问题。

For Release Hash: 对于释放哈希:

  1. Run this command on your release apk to print all the certificate 在您的发行版apk上运行此命令以打印所有证书

     keytool -list -printcert -jarfile <your apk path> 
  2. Copy the SHA1 value Go to http://tomeko.net/online_tools/hex_to_base64.php and convert your SHA1 hex value to Base64 复制SHA1值转到http://tomeko.net/online_tools/hex_to_base64.php并将SHA1十六进制值转换为Base64

  3. The value i got is different from the value i got from regular release keystore command. 我得到的值与我从常规发布密钥库命令获得的值不同。

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: 这适用于Debug Hash:

The above method will work for the debug apk too. 上面的方法也适用于调试apk。 but this is how i got the hash for debug apk and it's different from given keystore command. 但这是我如何获得调试apk的哈希值,它与给定的keystore命令不同。

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. 这对我有用,我还没有理解这里发生的事情。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:Google API v.3提供INVALID_REQUEST,但在浏览器中执行良好 - Android : Google API v.3 gives INVALID_REQUEST , but executed good in the browser 谷歌日历 API Java 400 invalid_request - Google Calendar API Java 400 invalid_request Google Places API,添加位置始终返回INVALID_REQUEST - Google Places API, Adding a place always returns INVALID_REQUEST 使用搜索API将具有重复字段名称的文档添加到索引时出现INVALID_REQUEST异常 - INVALID_REQUEST exception when adding a document with repeated field names to an index with the search API 添加位置后,Google Places POST“ INVALID_REQUEST”响应 - Google Places POST “INVALID_REQUEST” response when adding a place 无法将dex与添加到项目中的LinkedIn SDK合并? - Unable to merge dex with LinkedIn SDK added into project? Apache Oltu + Microsoft集成-OAuthProblemException {error =&#39;invalid_request&#39;,description =&#39;缺少必需的参数,包括无效的参数 - Apache Oltu + Microsoft Integration - OAuthProblemException{error='invalid_request', description='missing required parameters, includes an invalid 用于获取访问令牌的Google oauth java客户端失败,并显示“400 Bad Request {”error“:”invalid_request“}” - Google oauth java client to get an access token fails with “400 Bad Request { ”error“ : ”invalid_request“ }” 用于获取访问令牌的Google oauth java客户端失败,并显示“400 Bad Request {”error“:”invalid_request“}” - Google oauth java client to get an access token fails with “400 Bad Request { ”error“ : ”invalid_request“ }” 适用于Android应用的Linkedin Api查询 - Linkedin Api Queries for Android Apps
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM