android linkedIn integration- access token not received

问题描述 投票:0回答:1

我必须在android应用程序中与linkedIn集成。但我没有获得访问代码。我试了很多但没用。这是我的代码..

 LISessionManager.getInstance(getApplicationContext()).init(this, buildScope(), new AuthListener() {
                @Override
                public void onAuthSuccess() {

                    Log.e("LinkedIn", "User Loged in");
                    Toast.makeText(getApplicationContext(), "success" + LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString(), Toast.LENGTH_LONG).show();

                    //    LISessionManager.getInstance(getApplicationContext().getSession().getAccessToken().toString(), Toast.LENGTH_LONG).show();</p>
                    String authToken = LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString();
                    Log.e("LinkedIn auth token", authToken);

                    shareLinkedInContent();
                }

                @Override
                public void onAuthError(LIAuthError error) {
                    // Handle authentication errors
                    Log.e("LinkedIn", error.toString());
                }
            }, true); 




         private void shareLinkedInContent() {

        String url = "https://api.linkedin.com/v1/people/~/shares";
        Log.e("LinkedIn", "Posted" + url);
        try {
            JSONObject body = new JSONObject("{" +
                    "\"comment\": \"Sample share\"," +
                    "\"visibility\": { \"code\": \"anyone\" }," +
                    "\"content\": { " +
                    "\"title\": \"Sample share\"," +
                    "\"description\": \"Testing the mobile SDK call wrapper!\"," +
                    "\"submitted-url\": \"http://www.example.com/\"," +
                    "\"submitted-image-url\": \"http://www.example.com/pic.jpg\"" +
                    "}" +
                    "}");
            Log.e("LinkedIn", "Posted" + url);

            APIHelper apiHelper = APIHelper.getInstance(getApplicationContext());

            apiHelper.postRequest(this, url, body, new ApiListener() {
                @Override
                public void onApiSuccess(ApiResponse apiResponse) {
                    // Success!
                    Log.e("LinkedIn post success", "Posted");
                }

                @Override
                public void onApiError(LIApiError liApiError) {
                    Log.e("LinkedIn post error", liApiError.getMessage());
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }

我得到了像{“expiresOn”:0}这样的身份验证令牌,并且没有设置共享部分给予访问权限

我使用了here的最新LinkedId SDK。

我不知道如何解决这个问题。如果有人知道,请告诉我......

android linkedin social
1个回答
1
投票

此SDK已弃用,将于3月1日删除APIv1。

Please see

Also you can see the migration guide on his official docs

© www.soinside.com 2019 - 2024. All rights reserved.