How to exit LinkedIn using authrequest using Android?

I developed one application integrated with linkedIn ..! I am performing SignIn authentication on linkedIn using the OAuth service to post a network update ... but now, how to automatically deactivate (deactivate authentication) on LinkedIn?

Thanks in adv ..

+5
source share
2 answers

According to the official blog

Token Invalidity

Now you can revoke the OAuth token for your application. Just send a GET request signed by OAuth to:

https://api.linkedin.com/uas/oauth/invalidateToken

A response of 200 means that the token has been successfully revoked.

:

LinkedIn - -. , , LinkedIn , -.

, : Linked In

+7

, , Mr. Nabeel Siddiqui - API

, , linkedin-j api?

LinkedInOAuthService # invalidateAccessToken, . , , , , . , .

.

    final LinkedInOAuthService oAuthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(consumerKey, consumerSecret);
    final LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(consumerKey, consumerSecret);
    LinkedInRequestToken liToken;
    LinkedInApiClient client;
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        liToken = oAuthService.getOAuthRequestToken(CALLBACKURL);
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(liToken.getAuthorizationUrl()));
        startActivity(i);
    }
    @Override
    protected void onNewIntent(Intent intent) 
    {
        super.onNewIntent(intent);
        Uri uri = intent.getData();

        if (uri != null && uri.toString().startsWith(CALLBACKURL)) 
        {
            String verifier = intent.getData().getQueryParameter("oauth_verifier");

            LinkedInAccessToken accessToken = oAuthService.getOAuthAccessToken(liToken, verifier);
            client = factory.createLinkedInApiClient(accessToken);
            Connections con = client.getConnectionsForCurrentUser();

            //AFTER FETCHING THE DATA I HAVE DONE

             oAuthService.invalidateAccessToken(accessToken);
           //this is for sign out

        }
    }

, , .

SourceCode API- LinkedInOAuthServiceImpl.java

, , .

@Override
    public void invalidateAccessToken(LinkedInAccessToken accessToken) {
        if (accessToken == null) {
            throw new IllegalArgumentException("access token cannot be null.");
        }
        try {
            URL               url     = new URL(LinkedInApiUrls.LINKED_IN_OAUTH_INVALIDATE_TOKEN_URL);
            HttpURLConnection request = (HttpURLConnection) url.openConnection();

            final OAuthConsumer consumer = getOAuthConsumer();
            consumer.setTokenWithSecret(accessToken.getToken(), accessToken.getTokenSecret());
            consumer.sign(request);
            request.connect();

            if (request.getResponseCode() != HttpURLConnection.HTTP_OK) {
                throw new LinkedInOAuthServiceException(convertStreamToString(request.getErrorStream()));
            }
        } catch (Exception e) {
            throw new LinkedInOAuthServiceException(e);
        }
    }
0

All Articles