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 deniedAfter 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");You gotta love the reflection API.
final Field modifiersField = java.lang.reflect.Field.class.getDeclaredField("modifiers");
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(null, LinkedInApiUrls.LINKED_IN_OAUTH_REQUEST_TOKEN_URL + "?scope=rw_nus+r_basicprofile");
I can't really take the credit for the solution, I found it on stackoverflow.