My company’s software is providing Twitter Ads API support for a customer that is sending a large volume of data to Twitter. Periodically we receive a HTTP 401 response from version 3 of the REST API. We are in the process to updating our software to use version 4.
As a result of receiving the 401 response, we automatically fault the endpoint - that is we prevent any further interaction with Twitter for that set of credentials until the customer updates their credentials.
This was based on this line from the Twitter docs for the Unauthorized return code:
"Missing or incorrect authentication credentials. This may also returned in other undefined circumstances."
Using our tools, I have verified that the credentials are still valid, and the customer doesn’t need to update their credentials to proceed.
My question is:
Is there something in the response where my code can differentiate between what is legitimately invalid credentials and “undefined circumstances”, so I don’t fault the endpoint?