LinkedIn access token is null when using Android SDK - android

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.

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.

Related

LinkedIn oauth 2.0 for Android

How do I implement oauth 2.0 in Android? I was able to obtain a token but
https://api.linkedin.com/v1/people/~:(email-address,first-name,last-name)?oauth2_access_token=
was not able to verify it. How do I send my client id as parameter? I used the following code to authenticate.
LISessionManager.getInstance(getApplicationContext()).init(this, buildScope(), new AuthListener() {
#Override
public void onAuthSuccess() {
LISessionManager liSessionManager = LISessionManager.getInstance(getApplicationContext());
handleLinkedIn(liSessionManager);
Log.d( "success", LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString());
}
#Override
public void onAuthError(LIAuthError error) {
Toast.makeText(getApplicationContext(), "failed " + error.toString(), Toast.LENGTH_LONG).show();
}
}, true);
I used this method to obtain the access token.
LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken().toString()
That is not the correct access token that you are sending. See this example get access token from linkedIn

Getting the logged in user info from ADAL on android

I am working with ADAL from
https://github.com/Azure-Samples/active-directory-android
My code mimics the sample very close
mAuthContext.acquireToken(ToDoActivity.this, Constants.RESOURCE_ID,
Constants.CLIENT_ID, Constants.REDIRECT_URL, Constants.USER_HINT,
new AuthenticationCallback<AuthenticationResult>() {
#Override
public void onError(Exception exc) {
if (mLoginProgressDialog.isShowing()) {
mLoginProgressDialog.dismiss();
}
Toast.makeText(getApplicationContext(),
TAG + "getToken Error:" + exc.getMessage(), Toast.LENGTH_SHORT)
.show();
navigateToLogOut();
}
#Override
public void onSuccess(AuthenticationResult result) {
if (mLoginProgressDialog.isShowing()) {
mLoginProgressDialog.dismiss();
}
if (result != null && !result.getAccessToken().isEmpty()) {
setLocalToken(result);
sendRequest();
} else {
navigateToLogOut();
}
}
});
I pass in the user's email address, but if the user changes it and uses a different one the ADAL library on the onSuccess never tells me the user changed it. The AuthenticationResult has a field calls mUserInfo that that should contain user's first name/last name email etc.
But for me every successful login mUserInfo=null.
Anyone know how to get ADAL to return a fully populated mUserInfo object?
thanks
Tom
Userinfo is constructed from the ID_token retuned from the server. In case of adfs blue (3.0), it does not return an ID_token and hence you cannot truly know what user signed in at the IDP. Adfs threshold supports ID_token if you can upgrade.

Android Linkedin SDK DeepLink automatically crash

I am trying to "Deeplink" to some user profile on my Android application
but the app always reacts the same way. It opens the offical Linkedin Application, which crashes immediatly, and then it doesn't enter in the callback (onDeepLinkError)...
I tried both openCurrentProfile and openOtherProfile methods...
My session is valid, and I am authenticated, everything's good on that side.
Here is my piece of code :
DeepLinkHelper deepLinkHelper = new DeepLinkHelper();
deepLinkHelper.openCurrentProfile(getActivity(), new DeepLinkListener() {
#Override
public void onDeepLinkSuccess() {
}
#Override
public void onDeepLinkError(LIDeepLinkError error) {
Log.e("ERROR", error.toString());
}
});
EDIT : It seems to crash only on my smartphone, I ran the app on a friend device, and I works properly... Any ideas would be extremely apprieciated :D

FACEBOOK/TWITTER login no longer work on Android app after updating Facebook APK (login disappears immediately!)

I have an App that allows users to log in with their twitter, facebook, and gmail so I can send them updates to each. I just downloaded the newest facebook APK and now I every time I click on the twitter or facebook logins, the login only shows up for a split-second and then disappears. Here's what I've changed:
public static Facebook load(Context context) {
Facebook fb = new Facebook(context.getString(R.string.facebook_App_ID));
restore(fb, context);
return fb;
}
--It didn't used to take the APP_ID as a parameter but the new APK enforces you to do it here I believe.
facebook.authorize(this, PERMISSIONS,new LoginDialogListener());
-- This previously took the APP_ID as a parameter but now it is passed in when the facebook object is created.
--NOTE: I already tried using FORCE_DIALOG_AUTH and that did not work.
private final class LoginDialogListener implements DialogListener
{
public void onComplete(Bundle values) {
System.out.println("fb success");
FacebookHelper.save(facebook, SMTPSettings.this);
updateFacebookSumamry();
}
public void onFacebookError(FacebookError error) {
L.p("loginDialogListener",4900374);
System.out.println("fb error " + error.getMessage());
}
public void onError(DialogError error) {
L.p("loginDialogListener",4900387);
System.out.println("fb error " + error.getMessage());
}
public void onCancel() {
L.p("loginDialogListener",4900392);
System.out.println("fb cancel");
}
}
-I haven't changed anything with my dialogListener. But every time the control moves to the Dialoglistener it just goes straight into the onError function.
Twitter login no longer works but gmail still does. I don't know exactly what i changed that makes twitter no longer work too, but any help or tips would be greatly appreciated!
Thanks!
For anyone that has seen this, I thought I might post what I remember solved the problem. I uninstalled the other facebook apps I had on my phone like Andreas said above. That didn't solve it immediately, but restarting the phone made it work perfectly. I think it had to do with clearing out temporary memory files or something...not a very complicated problem, but all else fails, give it a clean restart!

Android Facebook API - sending an app invite to a friend

I managed to login to Facebook / get permissions.. retrieve friends data, names/ids etc.
The issue is that I cannot send an app invite to my friends. I'd like to send the invite without a dialog to a single person. But it seems that's wishful thinking. Now I'd settle for anything. It seems nothing will do the job!
I tried the dialog provided by Facebook Graph API but it tells me that the display is not supported (error 103). Also tried the fix modifying the url inside the Facebook SDK to not point to the mobile version and set the display as popup. Still no good (same error);
Any thoughts on this?
Thank you in advance.
(BTW, it seems to me like Facebook is a very unreliable service!)
This code will bring up an app invite dialog (and I don't know how to send an invite without a dialog). Note: assumes that facebook has been successfully authorized/logged in:
Facebook facebook = new Facebook( MY_APP_ID );
...
Bundle parameters = new Bundle();
parameters.putString( "message", "Check this out!" );
facebook.dialog( activity, "apprequests", parameters,
new Facebook.DialogListener()
{
public void onComplete() { ... }
public void onFacebookError( FacebookError e ) { ... }
public void onError(DialogError e) { ... }
public void onCancel() { ... }
} );

Categories

Resources