public void signInWithLinkedIn(View view){
LISessionManager.getInstance(getApplicationContext()).init(this, buildScope(), new AuthListener() {
@Override
public void onAuthSuccess() {
Toast.makeText(getApplicationContext(), "success" + LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().getValue(), Toast.LENGTH_LONG).show();
Log.d("SESSION", Boolean.toString(LISessionManager.getInstance(getApplicationContext()).getSession().isValid()));
//fetchBasicProfileData();
}
@Override
public void onAuthError(LIAuthError error) {
Toast.makeText(getApplicationContext(), "failed " + error.toString(),
Toast.LENGTH_LONG).show();
}
}, true);
// After complete authentication start new HomePage Activity
}
The block of code in onAuthSuccess
got executed but getSession returns null AND most importantly the access token is null, making me unable to call other linkedin APIs. This happens only recently. Am I doing it correctly?
Updated:- One more thing it generally happens with few specific LinkedIn Ids and working fine with rest of the id.
Implementing LinkedIn API in Android app helps users to login using LinkedIn account, share post, etc. For integrating the LinkedIn API in our Android app, we need the LinkedIn Authentication Key (Client ID and Client Secret) and app Hash Key. 1.
Fill all the required details of Android application in 'Create a New Application' form and accept the LinkedIn API Terms of Use then click 'Submit'. 3. After submitting the application details, it generates LinkedIn Authentication Key.
An access token could be invalid because it has expired or was revoked. When you integrate with the API, it is important to code your application to properly handle 401 Unauthorized errors. For example, if you receive the error, you can use the client ID and client secret to generate a new access token and retry your request.
If you call the LinkedIn Learning API with an invalid access token, you will receive a 401 Unauthorized error. An access token could be invalid because it has expired or was revoked. When you integrate with the API, it is important to code your application to properly handle 401 Unauthorized errors.
LinkedIn is updating its android sdk and they deprecate several methods.They started doing this from this week, I also got the same problem.You should use javascript api's to authenticate user rather than using linkedin android sdk.We fixed ur problem the same way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With