* BYE Session invalidated - AccessTokenExpired
OAUTH2 will expire the access token and end the session with the client. The client tries to reconnect however PasswordCMD is not called again, so the client tries reconnecting with the old access token which fails. The entire process then shuts down with a fatal error.
* BYE Session invalidated - AccessTokenExpired
WARN[4501] Done watching mailbox alias=office365 mailbox=INBOX
ERRO[4501] 0xc000524240
kKd8TA NO AUTHENTICATE failed.
INFO[4501] Restarting watcher for mailbox alias=office365 mailbox=INBOX
INFO[4501] Attempting TLS dialing
FATA[4501] Cannot select mailbox
My solution is to call retrievePasswordCmd whenever restarting a watcher.
client, fErr := newIMAPIDLEClient(retrievePasswordCmd(boxEvent.Conf))
Edited by Jake Nelson