When you created this thread there were questions to answer. Please answer all of them for the start. In case of log file, post it all - not just some snippet.
Then explain maybe in more details what it is you want to achieve.
"How to exit when there’s auth error?" is not clear at all. At least for me.