The Artima Developer Community
Sponsored Link

Java Buzz Forum
linkedin-j & Access to posting shares denied

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Erik C. Thauvin

Posts: 4232
Nickname: ethauvin
Registered: Apr, 2004

Erik C. Thauvin maintains one of the web's first and most popular linkblogs.
linkedin-j & Access to posting shares denied Posted: Dec 20, 2013 11:53 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Erik C. Thauvin.
Original Post: linkedin-j & Access to posting shares denied
Feed Title: Erik's Weblog
Feed URL: http://erik.thauvin.net/blog/feed.jsp?cat=Java
Feed Description: The Truth is Out There!
Latest Java Buzz Posts
Latest Java Buzz Posts by Erik C. Thauvin
Latest Posts From Erik's Weblog

Advertisement

This morning I noticed that my blog wasn't able to share on Linkedin anymore. I use the linkedin-j library to automatically share new blog posts on Linkedin. I rightfully assumed that my OAuth access token had expired. Upon resetting the token, I got the following error:

Access to posting shares denied
After a bit of research I was able to ascertain that the linkedin-j library was not requesting write access permission, which apparently is now required.

If was able to fix the problem by adding the following code right before the token request:
final Field field = LinkedInApiUrls.class.getField("LINKED_IN_OAUTH_REQUEST_TOKEN_URL");
field.setAccessible(true);
final Field modifiersField = java.lang.reflect.Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(null, LinkedInApiUrls.LINKED_IN_OAUTH_REQUEST_TOKEN_URL + "?scope=rw_nus+r_basicprofile");
You gotta love the reflection API.

I can't really take the credit for the solution, I found it on stackoverflow.

 

Read: linkedin-j & Access to posting shares denied

Topic: Strings in Switch case - Java 7 Tutorial and Example Previous Topic   Next Topic Topic: Workshop on Creating a Personal MusicManager Web Application with Struts2, Hibernate and MySQL

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use