Page 1 of 1

OAuth not working

Posted: Fri Sep 23, 2022 5:34 pm
by openrage
Script URL:
Version of script: 3.4.0
Hosting company: Hosted on site
What terms did you try when SEARCHING for a solution: OAuth

Write your message below:
While setting up OAuth everything went fine however when I save my Oauth provider I was not sent to Microsoft sign in only got Success: OAuth provider has been saved
When I went into IMAP Fetching and set everything up it tests successfully however emails are not being pulled in.
I set up cronjob to run hesk_imap.php but nothing.

Re: OAuth not working

Posted: Fri Sep 23, 2022 5:52 pm
by Klemen
What happens if you manually run hesk_imap.php in browser (step 5 in the article)?

Re: OAuth not working

Posted: Fri Sep 23, 2022 5:57 pm
by openrage
If I do that I receive the following

#!/usr/bin/php -q

Re: OAuth not working

Posted: Fri Sep 23, 2022 6:06 pm
by Klemen
Go to Admin > Settings > Help desk > under "Features" find "Debug mode", turn it off and save changes.

Then open the hesk_imap.php file again. What does it say now?

Re: OAuth not working

Posted: Fri Sep 23, 2022 6:10 pm
by openrage
I now get this however I have 3 unread messages in that inbox.

#!/usr/bin/php -q
Connected to the IMAP server "outlook.office365.com:993".
No unread messages found.
Disconnected from the IMAP server.

Re: OAuth not working

Posted: Fri Sep 23, 2022 6:24 pm
by Klemen
Are the unread messages maybe in a shared mailbox or somewhere? Office will only send emails from the actual inbox to Hesk.

How about if you mark them read, then unread again?

Re: OAuth not working

Posted: Fri Sep 23, 2022 6:27 pm
by openrage
messages are in a standard office 365 mailbox located in the inbox. I marked as read then back to unread and receive the same message.

Like I mentioned when I setup the OAuth provider I was not directed to sign into microsoft with my account.

Re: OAuth not working

Posted: Fri Sep 23, 2022 6:36 pm
by Klemen
What exact success message do you get if you go to Admin > Settings > Email and under IMAP Fetching click "Test connection"? How many messages are mentioned?

Re: OAuth not working

Posted: Fri Sep 23, 2022 6:38 pm
by openrage
Below is what I get

Success: Connection successful!

Number of emails your mail server will send to Hesk: 0

Re: OAuth not working

Posted: Fri Sep 23, 2022 6:47 pm
by Klemen
That means the connection works (you were probably logged in already when adding an OAuth provider), but nothing is sent over IMAP.

Not sure what to look for here. It wouldn't make sense that Office 365 would send a wrong status message over IMAP.

Are you sure the unread messages are in the INBOX, and not some other folder?
Can you send a screenshot of your Inbox folder (login at outlook.office365.com) to me in a private message?
Are you able to create a test email address in your O365 account and try connecting to that mailbox, to see if that makes any difference?

Re: OAuth not working

Posted: Fri Sep 23, 2022 6:59 pm
by openrage
PM Sent, also tested a different email in IMAP settings. Still was not prompted to login on OAuth providers and gave same messages.

Re: OAuth not working

Posted: Fri Sep 23, 2022 8:00 pm
by Klemen
For anyone else experiencing problems, try this:

1. delete the OAuth provider
2. open Hesk in a PRIVATE BROWSING window to make sure you are not logged in anywhere
3. add OAuth provider
4. when adding it and asked to login, make 100% sure you login with the email account you will use for Hesk

Re: OAuth not working

Posted: Mon Sep 26, 2022 7:22 am
by kerstens
Klemen wrote: Fri Sep 23, 2022 8:00 pm For anyone else experiencing problems, try this:

1. delete the OAuth provider
2. open Hesk in a PRIVATE BROWSING window to make sure you are not logged in anywhere
3. add OAuth provider
4. when adding it and asked to login, make 100% sure you login with the email account you will use for Hesk
I had the same issue, but this solved the problem. Thanks.

Re: OAuth not working

Posted: Mon Sep 26, 2022 12:16 pm
by Klemen
Great, I've added a notice about this to the Knowledgebase article.