According to our documentation:
unauthorized(401): represents an invalid token. If the TrueLayer token is expired, refreshing it should fix it. Otherwise, the end-user must re-authenticate.
unauthorizederrors may also happen if there are too many token refreshes prior to another request (balance, transactions, etc). This can mix up the
access_tokenused in the request. Only the last
access_denied(403): the user is successfully authorised but does not have permission to the particular request. Please ask the user to reconnect their account. This error is returned when the access to their account is no longer valid, either because it expired or because the user revoked it themselves.
Both issues do not happen during a token refresh, only when requesting data (accounts, balances, transactions, etc). For token refresh errors, check invalid_grant.
To learn more about these errors, check out our documentation.