Catch authentication errors. Closes #1581