Menu

#2127 OAuth IMAP cannot change folder, maybe it does not exist

3.0.2-1
assistance
None
Extension
Critical
2.6.0
defect
2023-01-05
2022-11-02
jym972
No

Hi,

I did a fresh setup of iTOP last version; Succeeded in setting up SSO with Azure MFA
Nevertheless, I block for 2 days seeting up oAuth IMAP with Azure

Could create Azure enterprise app, and create ServicePrincipal, and add permission on shared mailbox.
New-ServicePrincipal -AppId $entAppId -ServiceId $entObjId -Organization $tenantId -DisplayName 'ANVL-EXCH-SPN'
Add-MailboxPermission -Identity 'request@support.anvole.com' -User $entObjId -AccessRights FullAccess

When using script here, everything is fine and I can browse the imap mailbox

https://github.com/DanijelkMSFT/ThisandThat/blob/main/Get-IMAPAccessToken.ps1
.\Get-IMAPAccessToken.ps1 -clientsecret 'COm' -clientId f12851d -tenantID cbda***e31d -targetMailbox request@support.anvole.com
Accessing Sharedmailbox - request@support.anvole.com - with Accesstoken of User .
Connect to Office 365 IMAP Service.

  • OK The Microsoft Exchange IMAP4 service is ready. [UABSADA***NAA==]
    Authenticate using XOAuth2.
    A01 OK AUTHENTICATE completed.
    Getting mailbox folder list as authentication was successfull.
  • LIST (\HasNoChildren) "/" Archive
  • LIST (\HasNoChildren) "/" Calendar
  • LIST (\HasChildren) "/" Contacts
  • LIST (\HasChildren) "/" "Conversation History"
  • LIST (\HasNoChildren \Trash) "/" "Deleted Items"
  • LIST (\HasNoChildren) "/" done
  • LIST (\HasNoChildren \Drafts) "/" Drafts
  • LIST (\Marked \HasChildren) "/" INBOX
  • LIST (\HasNoChildren) "/" INBOX/done
  • LIST (\HasNoChildren) "/" Journal
  • LIST (\HasNoChildren \Junk) "/" "Junk Email"
  • LIST (\HasNoChildren) "/" Notes
  • LIST (\HasNoChildren) "/" Outbox
  • LIST (\HasNoChildren \Sent) "/" "Sent Items"
  • LIST (\HasNoChildren) "/" Tasks
    A01 OK LIST completed.
    Logout and cleanup sessions.
  • BYE Microsoft Exchange Server IMAP4 server signing off.

When using iTOP IMAP oAuth, token is well created, when retrieving emails, always getting "cannot change folder, maybe it does not exist"

2022-11-02 02:11:40 | Debug | 17 | IMAPOAuthEmailSource Start for outlook.office365.com | OAuth |||
2022-11-02 02:11:41 | Debug | 17 | IMAP Sending: TAG1 AUTHENTICATE XOAUTH2 dXNlcj1yZXF1ZXNBAQ== | OAuth |||
2022-11-02 02:11:41 | Debug | 17 | IMAP Oauth sending AUTHENTICATE XOAUTH2 user=request@support.anvole.com auth=Bearer eyJ0eXAiOiJ
zG1m3g | OAuth |||
2022-11-02 02:11:41 | Debug | 17 | IMAP Receive: TAG1 OK AUTHENTICATE completed. | OAuth |||
2022-11-02 02:11:41 | Debug | 17 | IMAP Oauth receiving OK AUTHENTICATE completed. | OAuth |||
2022-11-02 02:11:41 | Debug | 17 | IMAP Sending: TAG2 SELECT "INBOX" | OAuth |||
2022-11-02 02:11:41 | Debug | 17 | IMAP Receive: TAG2 BAD User is authenticated but not connected. | OAuth |||
2022-11-02 02:11:41 | Debug | 17 | IMAP Sending: TAG3 LOGOUT | OAuth |||
2022-11-02 02:11:41 | Debug | 17 | IMAP Receive: * BYE Microsoft Exchange Server IMAP4 server signing off. | OAuth |||
2022-11-02 02:11:41 | Debug | 17 | IMAP Receive: TAG3 OK LOGOUT completed. | OAuth |||
2022-11-02 02:11:41 | Error | 17 | Failed to initialize the mailbox: request@support.anvole.com. Reason: cannot change folder, maybe it does not exist | IssueLog |||

Discussion

  • Jeffrey Bostoen

    Jeffrey Bostoen - 2022-11-02

    Not sure if it's case sensitive or not; isn't it usually "Inbox" ?

     
  • jym972

    jym972 - 2022-11-02

    No, same issue
    And it seems not to be case sensitive as the powershell script list all folders and gives a "INBOX" folder as you can see in attachment

    https://github.com/DanijelkMSFT/ThisandThat/blob/main/Get-IMAPAccessToken.ps1

    .\Get-IMAPAccessToken.ps1 -clientsecret 'COom' -clientId f12851d -tenantID 'cbda***31d' -targetMailbox request@support.anvole.com
    Accessing Sharedmailbox - request@support.anvole.com - with Accesstoken of User .
    Connect to Office 365 IMAP Service.

    • OK The Microsoft Exchange IMAP4 service is ready. [UAB***MATwBNAA==]
      Authenticate using XOAuth2.
      A01 OK AUTHENTICATE completed.
      Getting mailbox folder list as authentication was successfull.
    • LIST (\HasNoChildren) "/" Archive
    • LIST (\HasNoChildren) "/" Calendar
    • LIST (\HasChildren) "/" Contacts
    • LIST (\HasChildren) "/" "Conversation History"
    • LIST (\HasNoChildren \Trash) "/" "Deleted Items"
    • LIST (\HasNoChildren) "/" done
    • LIST (\HasNoChildren \Drafts) "/" Drafts
      *** LIST (\Marked \HasChildren) "/" INBOX**
    • LIST (\HasNoChildren) "/" INBOX/done
    • LIST (\HasNoChildren) "/" Journal
    • LIST (\HasNoChildren \Junk) "/" "Junk Email"
    • LIST (\HasNoChildren) "/" Notes
    • LIST (\HasNoChildren) "/" Outbox
    • LIST (\HasNoChildren \Sent) "/" "Sent Items"
    • LIST (\HasNoChildren) "/" Tasks
      A01 OK LIST completed.
      Logout and cleanup sessions.
    • BYE Microsoft Exchange Server IMAP4 server signing off.
     
  • jym972

    jym972 - 2022-11-08

    OK, could solve it with a brand new Azure AD Tenant, with less security

     
    • Peter van der Kleij

      Hi Jean-Yves,
      Was this the solution? What did you do exactly?

      I have it working for months, Today it suddenly stopped working.
      "Failed to initialize the mailbox: xxx@xxx.nl Reason: cannot change folder, maybe it does not exist"

      I checked the application in Azure, but everything seems still ok. The token is also still valid.
      The SMTP function also still works, iTop still sends e-mails.

      Tried to enable Debug Trace. also set 'debug to True' under "combodo-email-synchro". But i couldn't get any trace information out of it.

      iTop version: 3.0.2-1-9957
      Mail to ticket automation Version: 3.6.0
      ran: apt-get update && upgrade

      Maybe its a whole different problem, so maybe have to create a new topic for this.

       
      • Peter van der Kleij

        since last night 2:00am it suddenly works again... i guess a hickup in Azure, but had no service health messages/alerts in Azure....

         
  • Romain Baillade

    Romain Baillade - 2022-11-23

    Hello, Jean-Yves.
    What rights gave you to application in Azure AD.
    Thanks a lot.

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-12-08

    Thanks for the feedbacks Jean-Yves !
    Closing ticket.

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-12-08
    • status: new --> assistance
    • assigned_to: Pierre Goiffon
     

Log in to post a comment.

MongoDB Logo MongoDB