Generating a new authentication code programmatically

When you use this code, the API returns an access token and a refresh token.

When the access token expires, use the refresh token to get a new access token.

TLDR: you are storing and attempting to use the wrong thing to get a new access token.