Issue
I'm trying to integrate my app with LinkedIn, but I'm not getting an access code.
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();
}
}
I get an auth token like {"expiresOn":0}
and share section gives "access token is not set"
I used the latest LinkedId SDK from here.
Solution
This SDK has been deprecated, in March 1 the APIv1 will be delete.
Also you can see the migration guide on his official docs
Answered By - Osmar I. Cancino
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.