Merge changes from release v0.3.1
Improve handling error response from token request
Retry request with new token if token becomes invalid
Upgrade request dependency to v2.27.0
Set version to v0.4.0 and add history
Release v0.4.0