Menu

OAuth Office 365 connection

2023-04-03
2025-03-19
  • Cristian Ozan

    Cristian Ozan - 2023-04-03

    Hello

    I'm trying to connect to IMAP using the Azure Portal. I already generated my access token, but I'm getting the following error: "Reason: cannot change folder, maybe it does not exist." I've attached some screenshots.

     
  • Cristian Ozan

    Cristian Ozan - 2023-04-03

    I forgot to mention that my iTop version is 3.0.2 and I try in two versions of php (7.4 and 8.0).

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2023-04-04

    Make sure that the user account which was used to generate the token, also has proper full access permissions on the mailbox (Exchange Online).

     
  • Cristian Ozan

    Cristian Ozan - 2023-04-04

    I use the Administrator user for the token generation, and the mailbox has de correct permition. I dont know where is the error.

     
  • Cristian Ozan

    Cristian Ozan - 2023-04-04

    This is the content of the error log file.

    2023-04-04 09:17:31 | Error | 601 | Failed to initialize the mailbox: itop@frro.utn.edu.ar. Reason: cannot change folder, maybe it does not exist | IssueLog

    array (
    'file' => '/var/www/html/itop/lib/laminas/laminas-mail/src/Storage/Imap.php',
    'line' => 384,
    'exception.class' => 'Laminas\Mail\Storage\Exception\RuntimeException',
    'exception.stack' => '#0 /var/www/html/itop/env-production/combodo-oauth-email-synchro/src/Service/IMAPOAuthStorage.php(53): Laminas\Mail\Storage\Imap->selectFolder()

    **####1 /var/www/html/itop/env-production/combodo-oauth-email-synchro/src/Service/IMAPOAuthEmailSource.php(57): Combodo\iTop\Extension\Service\IMAPOAuthStorage-> construct()

     
  • Cristian Ozan

    Cristian Ozan - 2023-04-04

    Also I give several permitions in API Secctions.

    Any help will be appreciated.

    Cristian

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2023-04-04

    You might see more after enabling the debug trace.

     
  • Cristian Ozan

    Cristian Ozan - 2023-04-04

    The debug tracer is enabled, but I can´t get any information other than the information it has given to me.

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2023-04-05

    Different one perhaps. Not sure if it will help, assuming all your permissions are OK:
    https://www.itophub.io/wiki/page?id=2_7_0:admin:oauth#troubleshooting

    Might also help to re-generate the token.

    Make sure the user who consents to the permissions, also has the "full access" permission on Microsoft Exchange Online to this mailbox.

     

    Last edit: Jeffrey Bostoen 2023-04-05
  • Cristian Ozan

    Cristian Ozan - 2023-04-05
    Yes is enabled too.
    
    'log_level_min' => array (
        'OAuth' => 'Debug',
    ),
    Office 365 I hate you!!!
    
     
  • Luis Felipe Rodríguez

    I have the same problem. Debus trace shows nothing despite being active but in error.log : Failed to initialize the mailbox: XXXX@XXX.XXX. Reason: cannot change folder, maybe it does not exist

    'file' => '/itop/lib/laminas/laminas-mail/src/Storage/Imap.php',
    'line' => 404,
    'exception.class' => 'Laminas\Mail\Storage\Exception\RuntimeException',

    I have tried with INBOX, Inbox and empty without success. Azure permissions are assigned

    Microsoft Graph MailboxFolder.ReadWrite.All Read and write all the users' mailbox folders
    Microsoft Graph MailboxSettings.ReadWrite Read and write all user mailbox settings
    Microsoft Graph email View users' email address
    Microsoft Graph IMAP.AccessAsUser.All Read and write access to mailboxes via IMAP.
    Microsoft Graph offline_access Maintain access to data you have given it access to

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2025-03-19

    Can you show the config in iTop? In particular, the "scope".

     

Log in to post a comment.