strava
strava copied to clipboard
Fix refresh_token middleware retry
We were overriding the original Tesla.env with the response from the failed request. The failed request already had a status (401) and a body (json containing Authorization Error).
This change keeps the original Tesla.env and only updates the authorization header after using the refresh_token.
Let me know what you think about the tests. I wasn't sure how to test just the middleware so I wrote a test for the client instead.