Fixed bugs related to the automatic refresh of access tokens