Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Reading your question i have also tried to find solution and also talked to <strong>Mr. Nabeel Siddiqui - Author of linkedin-j API</strong> </p> <p>and this was his reply when i asked if it's possible to sign out using linkedin-j api?</p> <p><strong>Hi Mayur There is a method LinkedInOAuthService#invalidateAccessToken that is supposed to invalidate your access token. Its not used much by the community so I am not sure if it works as expected or not. Do try it and let me know if there are problems. Regards Nabeel Mukhtar</strong></p> <p>so in my activity i tried it using this way.</p> <pre><code> 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 &amp;&amp; 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 } } </code></pre> <p>Please, Try this way once and tell me if it solves your problem.</p> <p>cause I have also donwloaded and seen the SourceCode for linkedin-j API and in <strong>LinkedInOAuthServiceImpl.java</strong></p> <p>they have given the function and that function also works if we write the same code in our file. that is,</p> <pre><code>@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); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload