Can not get access token from LinkedIn app. It is

2020-07-17 15:12发布

问题:

I am using linkedIn android sdk to sign in to app but cannot get the access token.

void startAutheniticate() {
    LISessionManager.getInstance(getApplicationContext()).init(this,
            buildScope(),
            new AuthListener() {
                @Override
                public void onAuthSuccess() {
                    // Saved AccessToken
                    AccessToken accessToken = LISessionManager.getInstance(getApplicationContext()).getSession().getAccessToken();
                }

                @Override
                public void onAuthError(LIAuthError error) {

                }
            }, true);
}

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


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    LISessionManager.getInstance(getApplicationContext()).onActivityResult(this, requestCode, resultCode, data);
}

Need the access token

onActivityResult()

回答1:

They have deprecated the v1 implementation but haven't yet updated their LinkedIn app (nor SDK) on Android, so the only solution available is to use their JavaScript API to authenticate your applications via v2 implementation.

Plus they said that developers had time until March 1, 2019 but for some reason their Android application is now returning a null token (starting from January 14, 2019) if you try to use the LinkedIn SDK to authenticate your app

Here is the link of their updated v2 APIs for Sign In with LinkedIn