Menu

Error OAuth 2.0

2024-12-20
2025-01-20
  • Bon Cédric

    Bon Cédric - 2024-12-20

    Hello,

    I have an error to connect mailbox with OAuth 2.0, iv'e create an application on office 365 to connect on the OAuth 2.0, and configure the mailbox, when i try to connect it i have this error :

    Failed to initialize the mailbox: " Reason: cannot connect to host; error = stream_socket_client(): Unable to connect to ssl://outlook.office365.com:993 (Unknown error) (errno = 0 )

     
    • Kirk Thompson

      Kirk Thompson - 2024-12-20

      Try to nmap to outlook.office365.com:993. Is the port open? Can you even
      get to that server? If not, may be a firewall blocking issue on your side
      (or theirs).

      On Fri, Dec 20, 2024, 06:28 Bon Cédric cedric93@users.sourceforge.net
      wrote:

      Hello,

      I have an error to connect mailbox with OAuth 2.0, iv'e create an
      application on office 365 to connect on the OAuth 2.0, and configure the
      mailbox, when i try to connect it i have this error :

      Failed to initialize the mailbox: " Reason: cannot connect to host; error
      = stream_socket_client(): Unable to connect to ssl://
      outlook.office365.com:993 (Unknown error) (errno = 0 )


      Error OAuth 2.0
      https://sourceforge.net/p/itop/discussion/integrating-itop/thread/11d39b47bb/?limit=25#cbd7


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/itop/discussion/integrating-itop/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
      👍
      1
    • Jeffrey Bostoen

      Jeffrey Bostoen - 2024-12-21

      You were able to generate a proper OAuth 2.0 token?

      Can you show a screenshot of your settings? (censor email)

       
  • Bon Cédric

    Bon Cédric - 2025-01-06

    Hello, please find the screenshot.

    Yes the token from office is generate with succes.

     

    Last edit: Bon Cédric 2025-01-06
  • Stephen Abello

    Stephen Abello - 2025-01-06

    Hi,

    I would try what @kirkpthompson suggested. Your server might not be able to send requests outside.
    When generating your token for the first time, only your browser communicates with the distant service, not the iTop server.

     
  • Bon Cédric

    Bon Cédric - 2025-01-07

    Hi,

    Ive chek our serveur and is able to send request outside the port 993 is open.

     
  • Bon Cédric

    Bon Cédric - 2025-01-13

    Hello any news ? please

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2025-01-13

    Based on the screenshots and message, I don't think there will be many other suggestions to be honest?

    But you could try to reach out to Combodo for a more in-depth investigation, or perhaps do some more research on the message you're seeing to try out different solutions, or contact an iTop consultant (such as myself) to outsource the troubleshooting.

     
  • Stephen Abello

    Stephen Abello - 2025-01-13

    Can you show us your combodo-email-synchro part of your configuration file ?
    There's some parameters that can be passed to your imap_options that'll be used when trying to connect to the remote server ( link ssl or novalidate-cert).

     
    👍
    1
  • Bon Cédric

    Bon Cédric - 2025-01-15

    This is the part of email Synchro.

    ),
    'combodo-email-synchro' => array (
    'notify_errors_to' => '',
    'notify_errors_from' => '',
    'debug' => true,
    'periodicity' => 30,
    'retention_period' => 1,
    'body_parts_order' => 'text/html,text/plain',
    'pop3_auth_option' => 'USER',
    'imap_options' => array (
    0 => 'imap',
    1 => 'ssl',
    ),

     
  • Stephen Abello

    Stephen Abello - 2025-01-15

    Maybe your can try to add novalidate-cert to your imap_options in case that's a self signed certificate issue:

    'imap_options' => array (
    0 => 'imap',
    1 => 'ssl',
    2 => 'novalidate-cert'
    

    If that still fails you can try to connect to your mailbox using PHP in command line and see if you have similar issue:

    php -r 'imap_open("{outlook.office365.com:993/imap/ssl}", "username", "password");'
    
     
  • Bon Cédric

    Bon Cédric - 2025-01-16

    add the novalidate-cert don't work.

    I try the command to connect and the error is :

    Warning: imap_open(): Couldn't open stream {outlook.office365.com:993/imap/ssl} in Command line code on line 1
    PHP Notice: PHP Request Shutdown: LOGIN failed. (errflg=1) in Unknown on line 0

    Notice: PHP Request Shutdown: LOGIN failed. (errflg=1) in Unknown on line 0
    PHP Notice: PHP Request Shutdown: LOGIN failed. (errflg=1) in Unknown on line 0

    Notice: PHP Request Shutdown: LOGIN failed. (errflg=1) in Unknown on line 0
    PHP Notice: PHP Request Shutdown: LOGIN failed. (errflg=1) in Unknown on line 0

    Notice: PHP Request Shutdown: LOGIN failed. (errflg=1) in Unknown on line 0
    PHP Notice: PHP Request Shutdown: Too many login failures (errflg=2) in Unknown on line 0

    Notice: PHP Request Shutdown: Too many login failures (errflg=2) in Unknown on line 0

    That tell me the login is failed but my login used for connection is a good one.

     
  • Stephen Abello

    Stephen Abello - 2025-01-16

    The login failed is expected as Microsoft disallowed login/password authentication in IMAP, but at least we managed to get to the login process!

    Could you add (or replace) this entry in your configuration file and open the OAuth mailbox again (so the error message is displayed):

        'log_level_min' => ['OAuth' => 'Debug'],
    

    Then could you show us what's logged in your log/error.log file please ?

     
  • Bon Cédric

    Bon Cédric - 2025-01-17

    This is that i have i my error log file :

    2025-01-17 09:26:15 | Debug | 3 | IMAPOAuthEmailSource Start for outlook.office365.com | OAuth |||
    2025-01-17 09:26:15 | Error | 3 | Failed to initialize the mailbox: **(mailbox user). Reason: cannot connect to host; error = stream_socket_client(): Unable to connect to ssl://outlook.office365.com:993 (Unknown error) (errno = 0 ) | IssueLog |||
    array (
    'file' => 'C:\xampp\htdocs\itop\lib\laminas\laminas-mail\src\Protocol\ProtocolTrait.php',
    'line' => 110,
    'exception.class' => 'Laminas\Mail\Protocol\Exception\RuntimeException',
    'exception.stack' => '#0 C:\xampp\htdocs\itop\lib\laminas\laminas-mail\src\Protocol\Imap.php(118): Laminas\Mail\Protocol\Imap->setupSocket(\'ssl\', \'outlook.office3...\', 993, 30)

    C:\xampp\htdocs\itop\env-production\combodo-oauth-email-synchro\src\Service\IMAPOAuthStorage.php(48): Laminas\Mail\Protocol\Imap->connect(\'outlook.office3...\', 993, \'ssl\')
    C:\xampp\htdocs\itop\env-production\combodo-oauth-email-synchro\src\Service\IMAPOAuthEmailSource.php(51): Combodo\iTop\Extension\Service\IMAPOAuthStorage->__construct(Object(stdClass))
    C:\xampp\htdocs\itop\env-production\combodo-oauth-email-synchro\model.combodo-oauth-email-synchro.php(113): Combodo\iTop\Extension\Service\IMAPOAuthEmailSource->__construct(Object(MailInboxOAuth))
    C:\xampp\htdocs\itop\env-production\combodo-email-synchro\ajax.php(58): MailInboxOAuth->GetEmailSource()
    C:\xampp\htdocs\itop\env-production\combodo-email-synchro\ajax.php(256): GetMailboxContent(Object(Combodo\iTop\Application\WebPage\AjaxPage), Object(MailInboxOAuth))
    {main}',

    )
    2025-01-17 09:27:56 | Debug | 3 | GetAuthorizationUrl for OAuthClientAzure::3 | OAuth |||
    2025-01-17 09:27:58 | Debug | 3 | GetDisplayAuthenticationResults for OAuthClientAzure::3 | OAuth |||
    2025-01-17 09:27:58 | Info | 3 | Token recreated for OAuthClientAzure:3 | IssueLog |||
     
  • Stephen Abello

    Stephen Abello - 2025-01-17

    So this time it really can't open a socket to the remote server.
    I'm really not sure what's happening, I'll try to reproduce by installing a self signed certificated on my PC when I have some time

     
  • Bon Cédric

    Bon Cédric - 2025-01-20

    Ok thanks, we need to have a certificate on our computer ?

     
  • Stephen Abello

    Stephen Abello - 2025-01-20

    If your server uses SSL to secure a HTTPs connection you probably already have a certificate.
    If it's a self signed certificate it might lead to some issues as it's less common

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.