title: LinkedIn, 401, Unable to verify access token
body: <p>I used <a href="https://developer.linkedin.com/docs/oauth2" rel="nofollow noreferrer">this guide</a> to built a showcase - sign in with LinkedIn into a specific site.
  Everything worked <strong>perfectly</strong> until I demonstarted it in front of a wide audience and it broke down :-( It was a great FAIL and I want to know why. Here is what I do:</p>
  
  <p>1.On the sign in page the user may click a <code>Sign in with LinkedIn</code> button and is redirected to similar link:</p>
  
  <pre><code>https://www.linkedin.com/oauth/v2/authorization?redirect_uri=[my_callback]&amp;client_id=[my_client_id]&amp;response_type=code&amp;state=[securely_random]&amp;scope=r_basicprofile%20r_emailaddress
  </code></pre>
  
  <p>2.The user allows the application and is sent back to <code>my_callback</code></p>
  
  <p>3.In <code>my_callback</code> I make a POST to <code>https://www.linkedin.com/oauth/v2/accessToken</code> in order to obtain an access token. I use the code sent by LinkedIn, correct client ID and secret. Everything is OK, e.g the response might be:</p>
  
  <pre><code>{
      "access_token": [access_token],
      "expires_in": 5184000
  }
  </code></pre>
  
  <p>4.I make <em>authenticated requests</em> to fetch the profile data from endpoint <code>https://www.linkedin.com/v1/people/~:(firstName,lastName,email_address)</code></p>
  
  <p>Headers: </p>
  
  <pre><code>x-li-format: json       
  Authorization: Bearer [access_token]
  </code></pre>
  
  <p>I started to get an error 401 occasionally, e.g.:</p>
  
  <pre><code>{
    "errorCode": 0,
    "message": "Unable to verify access token",
    "requestId": "YX21AN6NZG",
    "status": 401,
    "timestamp": 1483732371224
  }
  </code></pre>
  
  <p>It seems that some of the requests randomly passed nevertheless...</p>
  
  <p>Additional details:</p>
  
  <ul>
  <li>The <a href="https://www.linkedin.com/in/lachezar-balev-a151626" rel="nofollow noreferrer">user</a> is logged in LinkedIn</li>
  <li>The user is administrator for the LinkedIn application</li>
  <li>I have checked the limitations (throttle limits) at in the application. Available at <code>https://www.linkedin.com/developer/apps</code>. Everything which can be seen is green.</li>
  <li>I have tried all advices and hacks from this <a href="https://stackoverflow.com/questions/28094926/linkedin-oauth2-unable-to-verify-access-token">question</a> </li>
  <li>My app is not live</li>
  </ul>
  
  <p>I'm puzzled!</p>
  
  <p><em>Question:</em> Any obvious mistake?</p>
  
  <p><em>Question:</em> Is there any hidden throttle limits (or security instruments) for the limitation of the number of access tokens for specific user/app combination? (I'm always using the same user and I tested pretty aggressively before the big FAIL)</p>
  
  <p><strong>UPDATE:</strong> In the next two days the Sign in started working smoothly again as described above. No 401-s anymore... :-X I've made no changes to the code base. So is this some kind of throttle limit or just LI was in a bad mood on Friday?</p>