I have an Atlassian Oauth2 app that accesses some Jira endpoints periodically. I am refreshing the access token every 40 mins using the refresh_token. I am getting a new refresh_token after refreshing the access token.
It was working as expected for a while, but recently, I got an error "Not in GZIP format" when attempting to refresh my access token. I am using Java Apache HTTP Client(4.5.13) to access Jira endpoints and to refresh my access_token. It supports gzip and deflates compressions out of the box. After some debugging, I saw this error may happen if the header contains "Content-Encoding": "gzip" but the content is not in gzip format.
As the nature of refresh_tokens, the old refresh_token became invalid after refreshing an access token and I can't refresh the acces_token anymore since the endpoint responded with invalid content and it is also invalidated my refresh_token. I have to go through the full OAuth flow again to obtain a valid refresh_token... Is there a way or best practice to avoid this kind of situation?