Office365 OAuth Verification Won't Work

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
jfriedman
Posts: 4
Joined: Mon Jun 05, 2023 1:50 am

Office365 OAuth Verification Won't Work

Post 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.
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Re: Office365 OAuth Verification Won't Work

Post 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)?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
jfriedman
Posts: 4
Joined: Mon Jun 05, 2023 1:50 am

Re: Office365 OAuth Verification Won't Work

Post 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.
jfriedman
Posts: 4
Joined: Mon Jun 05, 2023 1:50 am

Re: Office365 OAuth Verification Won't Work

Post 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?
jfriedman
Posts: 4
Joined: Mon Jun 05, 2023 1:50 am

Re: Office365 OAuth Verification Won't Work

Post 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 :)
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Re: Office365 OAuth Verification Won't Work

Post 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.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply