Mail fetching stopped, get error "User is authenticated but not connected"

Moderator: crythias

Post Reply
bjohnson
Znuny newbie
Posts: 5
Joined: 19 Dec 2022, 23:36
Znuny Version: 6.3
Real Name: Bruce Johnson
Company: University of Arizona College of Pharmacy

Mail fetching stopped, get error "User is authenticated but not connected"

Post by bjohnson »

Znuny version: LTS v 6.5.3 (just updated, but the error started under 6.4 ) using OAUTH2 to connect to an Office 365 mailbox.

I have confirmed the OAUTH2 secret is valid (expires in 2025) and token and refresh tokens are both valid. Everything is correct in Azure App registration; nothing has changed with either O365 or Znuny (except I went on vacation for a couple weeks :-x )

We were getting timeout errors, I saw another post viewtopic.php?f=62&t=43736 that said to update to IMAPS versus IMAPTLS.

Now I am getting the error 2 BAD User is authenticated, but not connected.

I am at a loss here.....

Partial output of command line fetch:

Code: Select all

-bash-4.2$ ./otrs.Console.pl Maint::PostMaster::MailAccountFetch --debug --force-pid

Spawning child process to fetch incoming messages from mail accounts...

outlook.office365.com (IMAPS)...
IMAPS: Connection to outlook.office365.com closed.

Started at Mon Jul 24 11:33:58 2023
Using Mail::IMAPClient version 3.43 on perl 5.016003
Connecting with IO::Socket::SSL PeerAddr outlook.office365.com PeerPort 993 Proto tcp Timeout 600 Debug 1 SSL_verify_mode 0
Connected to outlook.office365.com
Read: 	* OK The Microsoft Exchange IMAP4 service is ready. [UwBKADAAUABSADAANQBDAEEAMAAwADAAMwAuAG4AYQBtAHAAcgBkADAANQAuAHAAcgBvAGQALgBvAHUAdABsAG8AbwBrAC4AYwBvAG0A]
Sending: 1 AUTHENTICATE XOAUTH2
Sent 24 bytes
Read: 	+
Sending: [Redact: Count=1 Showcredentials=OFF]
Sent 3054 bytes
Read: 	1 OK AUTHENTICATE completed.
Sending: 2 SELECT INBOX
Sent 16 bytes
Read: 	2 BAD User is authenticated but not connected.
ERROR: 2 BAD User is authenticated but not connected. at /usr/local/share/perl5/Mail/IMAPClient.pm line 1388.
	Mail::IMAPClient::__ANON__('2 BAD User is authenticated but not connected.\x{d}\x{a}') called at /usr/local/share/perl5/Mail/IMAPClient.pm line 1424
	Mail::IMAPClient::_get_response('Mail::IMAPClient=HASH(0x4b15d50)', 2, undef) called at /usr/local/share/perl5/Mail/IMAPClient.pm line 1350
	Mail::IMAPClient::_imap_command_do('Mail::IMAPClient=HASH(0x4b15d50)', 'SELECT INBOX') called at /usr/local/share/perl5/Mail/IMAPClient.pm line 1248
	Mail::IMAPClient::_imap_command('Mail::IMAPClient=HASH(0x4b15d50)', 'SELECT INBOX') called at /usr/local/share/perl5/Mail/IMAPClient.pm line 864
	Mail::IMAPClient::select('Mail::IMAPClient=HASH(0x4b15d50)', 'INBOX') called at /opt/otrs/Kernel/System/MailAccount/IMAP.pm line 301
	eval {...} called at /opt/otrs/Kernel/System/MailAccount/IMAP.pm line 305
root
Administrator
Posts: 3970
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Mail fetching stopped, get error "User is authenticated but not connected"

Post by root »

Hi,

I guess that you probably requested a new token when the token was still valid. The error message indicates that the token is not working anymore.
Create a new token wth the same settings and make sure the user who accept the consent screen has permissions to the mailbox(es). Then replace the token in the mailbox configuration.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
bjohnson
Znuny newbie
Posts: 5
Joined: 19 Dec 2022, 23:36
Znuny Version: 6.3
Real Name: Bruce Johnson
Company: University of Arizona College of Pharmacy

Re: Mail fetching stopped, get error "User is authenticated but not connected"

Post by bjohnson »

I recreated the OAUTH2 app registration in Azure, applied it, got the expected acknowledgement of permissions when the token was fetched, but still no luck with fetching the emails.

running the fetch on the command line results in the same error, that the user is authenticated but not connected.

Do I need to clear out the inbox on the O365 side? We've been logging in to the account in outlook online just to be able to answer our Helpdesk.
bjohnson
Znuny newbie
Posts: 5
Joined: 19 Dec 2022, 23:36
Znuny Version: 6.3
Real Name: Bruce Johnson
Company: University of Arizona College of Pharmacy

Re: Mail fetching stopped, get error "User is authenticated but not connected"

Post by bjohnson »

Fixed it! I had to give my O365 account full rights to the mailbox then requested a new token and it worked.
root
Administrator
Posts: 3970
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Mail fetching stopped, get error "User is authenticated but not connected"

Post by root »

bjohnson wrote: 25 Jul 2023, 19:38 Fixed it! I had to give my O365 account full rights to the mailbox then requested a new token and it worked.
Hi,

Like I wrote: "make sure the user who accept the consent screen has permissions to the mailbox(es)."

Glad to hear it worked.

- Roy
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
Post Reply