fixed bug caused by clearing access token in case of error.