The "Fix"
After you change permissions, wait at least 5 minutes before testing.
Why?
There is a caching bug with LinkedIn API access tokens.
Generating a new access token SHOUD invalidate the previous token, but there is a 5 minute window when your new token might behave like an old token (using old permissions / scopes).
This makes LinkeIn API development very difficult. Any time a developer makes a change to the permission scopes, new tokens may throw (invalid) permission errors for several minutes, making it seem like the scope change didn't make any difference. Then a few minutes later, the new permissions will unexpectedly kick in, making it hard to reproduce the bug.
Bug Reported
I reported this to the LinkedIn Developer Support team with an app to prove it, and they responded...
After much discussion, team has confirmed they will consider this as part of product improvement but for now 5mins TTL is expected behavior. Developers usually don't have this pattern of trying to generate token for different combination of permissions. This is more like rare use case.
For now we have added this feedback to our roadmap. Unfortunately, we don't have concrete timeline as to when this will be implemented into production
I disagree. Changing permissions and generating new tokens is something that developers will do often, as they try to figure out what permissions are required for different API calls. I know I did it many times, especially after finding out that some of the API docs weren't being kept up to date... just had to keep remembering to wait 5 minutes before testing.
If you run into this issue please report the bug to LinkedIn, so they will see how many developers are bumping into this problem.
Version Upgrade Warning
This also creates a problem when upgrading the LinkedIn-Version. In version 202306, they changed the permission required on the /rest/me endpoint -- from r_liteprofile to r_basicprofile. This means that we will have to ask some customers to reauthorize their LinkedIn account, to get a new access token (with r_basicprofile scope). But they might run into this caching bug, and get permission errors, if their old token (with r_liteprofile) was used in the past 5 minutes.