Integration of Linkedin V2.0 / OAuth2.0 in Android app
Asked Answered
P

0

8

I have implemented LinkedIn sign-in functionality using linkedin-sdk in one of my application, which was working perfectly. Since last few days, I'm not able to proceed further with an error stating

access token is not set

which was not needed before.

With the update of version 2.0, the access token has been made compulsory and the details lacking in the developer account.

Warning message from LinkedIn attached.

I have implemented the same in this way:

private static final String host = "api.linkedin.com";

private static final String url = "https://" + host + "/v1/people/~:(first-name,last-name,email-address,formatted-name,phone-numbers,public-profile-url,picture-url,picture-urls::(original))";

LISessionManager.getInstance(getContext())
.init(getActivity(), buildScope(), new AuthListener() {

@Override
public void onAuthSuccess() {

APIHelper apiHelper = APIHelper.getInstance(getContext());
apiHelper.getRequest(getContext(), url, new ApiListener() {
@Override
public void onApiSuccess(ApiResponse apiResponse) {
try {
//edt_linkedInURL.setText(apiResponse.getResponseDataAsJson().get("publicProfileUrl").toString());
Log.e("Response", apiResponse.getResponseDataAsJson().toString());
setLinkedInData(apiResponse.getResponseDataAsJson());
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void onApiError(LIApiError LIApiError) {
Toast.makeText(getContext(), "Profile failed " + LIApiError.toString(), Toast.LENGTH_LONG).show();
}
});

/* Toast.makeText(getActivity(), "success" +
LISessionManager.getInstance(getActivity())
.getSession().getAccessToken().getValue(),
Toast.LENGTH_LONG).show();*/
}

@Override
public void onAuthError(LIAuthError error) {
try {
JSONObject object = new JSONObject(error.toString());
C.INSTANCE.showToast(getContext(), object.optString("errorMessage"));
} catch (Exception e) {
Toast.makeText(getContext(), "Failed to get data with LinkedIn", Toast.LENGTH_LONG).show();
}
}
}, true);

private static Scope buildScope() {
return Scope.build(Scope.R_BASICPROFILE, Scope.R_EMAILADDRESS, Scope.W_SHARE);

}

How can the access token be generated with details of how to integrate V2 / OAuth2.0 in app?

Poltergeist answered 22/1, 2019 at 11:21 Comment(4)
Have you some solution? I have the same problem :(Sisco
You have to implement OAuth2 signin. Basically, that means you have to add new activity with webview to handle signin process. Once webview load to redirect url, that means login success.Thorner
@Thorner You have any tutorial links or samples for OAuth2 signin linkedin sdk integration.Benz
@ArunRavichandran: I think https://mcmap.net/q/649462/-oauth-2-0-authorization-for-linkedin-in-android has the answer for your questionThorner

© 2022 - 2024 — McMap. All rights reserved.