LinkedIn seemingly does not appreciate when we fetch new access tokens while a valid one already exists. This has been observed to exhibit itself in the form of 429 errors suggesting that a user has reached a rate limit while trying to use a refresh token to fetch a new access token in discovery.
This change checks the expiration of an existing access_token (if one is present in the config) and proceeds with that token if so.
Manual QA steps
Tested locally with various access tokens.
Added several unittests.
Risks
Access Tokens could expire between checking the validity and issuing a request, and this does not provide handling for that case.
Description of change
LinkedIn seemingly does not appreciate when we fetch new access tokens while a valid one already exists. This has been observed to exhibit itself in the form of 429 errors suggesting that a user has reached a rate limit while trying to use a refresh token to fetch a new access token in discovery.
This change checks the expiration of an existing access_token (if one is present in the config) and proceeds with that token if so.
Manual QA steps
Risks
Rollback steps