I had the same Problem. So i checked two things, which solved it for me.
Checking the state queryparam. It has to contain (if you use OAuthWebSecurity) "__provider__=" and "__sid__=". (?__provider__=linkedin&__sid__=987654321)
Checking the appId and appSecret. Notice: Since OAuth2 there are two kinds of "keys" (appId and consumerKey are different). Same for the Secrets.
If you use OAuth2 only the appId and appSecret will work for you. Otherwise for OAuth(1) you have to choose the consumerKey and consumerSecret. (it wont work if you try to use the appId from oauth2 with the consumerSecret you will get the 401 error)
I hope this will solve your problem too.