Because there can be enough time between when _is_enphase_token_expired()
is called and when the subsequent http request to the envoy happens,
the token freshness check can pass but the envoy will still see an
expired token. This results in a 401 from the envoy, which raises
an exception.
This change looks for these 401s and attempts to refresh the
token twice before giving up.
Pull request recommendations:
[ ] Name your pull request your-development-type/short-description. Ex: feature/read-tiff-files
[ ] Link to any relevant issue in the PR description. Ex: Resolves [gh-12], adds tiff file format support
[ ] Provide context of changes.
[ ] Provide relevant tests for your feature or bug fix.
[ ] Provide or update documentation for any feature added by your pull request.
Because there can be enough time between when _is_enphase_token_expired() is called and when the subsequent http request to the envoy happens, the token freshness check can pass but the envoy will still see an expired token. This results in a 401 from the envoy, which raises an exception.
This change looks for these 401s and attempts to refresh the token twice before giving up.
Pull request recommendations:
Thanks for contributing!