Page 1 of 1

Office365 OAuth Verification Won't Work

Posted: Mon Jun 05, 2023 1:55 am
by jfriedman
Script URL:
Version of script: 3.4.3
Hosting company: Self-hosted
URL of phpinfo.php: PHP v8.0
URL of session_test.php:
What terms did you try when SEARCHING for a solution: Office365 OAuth, OAuth verification

Write your message below:
I am trying to setup Office365 OAuth provider so that I can use IMAP email fetching. I've created the OAuth provider following the instructions on the knowedgebase, yet it shows not verified. When I click the link to verify, it brings me to the Microsoft sign in page, I sign in with the support email, and it brings me back to the hesk page, still showing not verified.

Re: Office365 OAuth Verification Won't Work

Posted: Mon Jun 05, 2023 11:35 am
by Klemen
Hard to say what is going on without seeing it in action.

Are you able to provide, in a private message, admin access to your help desk, along with username and password for the support email address (or, even better, create a new TEST email address)?

Re: Office365 OAuth Verification Won't Work

Posted: Mon Jun 05, 2023 3:46 pm
by jfriedman
Unfortunately I cannot provide administrator access as per organization policy. However if there is some debugging steps you would like me to follow I would be happy to do that! Is there somewhere I can find logs from HESK? I don't see any errors in the web console and I can't seem to find any logs in the hesk folder. Also I have checked that the curl module is enable in php.

Re: Office365 OAuth Verification Won't Work

Posted: Mon Jun 05, 2023 4:24 pm
by jfriedman
I've done some further debugging. I can see that there is a row in the oauth_providers table however there is nothing in the oauth_tokens table. I can also see the requests made in the network tab of the Chrome Developer Tools. I can see the get request made to my oauth_providers.php page with the code query parameter. The response code was 301. I can see that it was redirected twice before getting to a status code 200. We are also using AWS Cloudfront in front of our site. Could this be what is causing the issue?

Re: Office365 OAuth Verification Won't Work

Posted: Mon Jun 05, 2023 4:50 pm
by jfriedman
Welp, I figured it out! I was in fact correct, cloudfront was stripping the code query parameter so it never got back to the server. I changed the cloudfront policy to forward query strings and cleared browser cache but it still didn't seem to work (wondering if maybe microsoft cached it?) but what I ended up doing to fix it was copy and paste the code parameter from the Network tab directly into my browser, and it verified! Hope this helps someone else with a similar problem :)

Re: Office365 OAuth Verification Won't Work

Posted: Mon Jun 05, 2023 5:22 pm
by Klemen
You have to love it when third-party providers modify your queries :D

Glad to hear you were able to fix it and thanks for sharing what worked for you.