Page 2 of 2

Re: Accessing emails on Office 365 via OAuth

PostPosted: Tue Oct 11, 2022 11:09 am
by robert.edelmann
Just a quick heads up, I updated the solution under
Code: Select all
https://github.com/RobertEdelmann1974/office365_test
, sending mails via Graph (an ugly affair featuring a prepared JSON-Object) and fetching messages / folders is supported.

One can't help but notice that Microsoft has a well structured approach to documenting Graph, like "if you want to read mails, you need that permission" + an interactive tool to experiment with the API. It feels almost like MS want's to nudge people in that direction.

Graph-Explorer is here: https://developer.microsoft.com/en-us/graph/graph-explorer
Documentation of Mail-Objects is here: https://learn.microsoft.com/en-us/graph/api/resources/mail-api-overview?view=graph-rest-1.0

Re: Accessing emails on Office 365 via OAuth

PostPosted: Tue Oct 18, 2022 4:02 pm
by robert.edelmann
robert.edelmann wrote:Even though I set the "Mail.Read.Shared/Mail.ReadWrite.Shared", I can't access shared folders, at least not in the way I can do it with basic authentication:


Ok, I found the way to access the shared accounts, just use the email-address of the shared account + the access-token of the user as name / password to log on, no extra steps required, which is nice, saves me the pressure to migrate to graph for mail under pressure.

Re: Accessing emails on Office 365 via OAuth

PostPosted: Wed Oct 19, 2022 10:00 am
by steve1376656734
Hi Robert,

Thanks to you (and everyone) for sharing your experience with this. I am sure it will be helpful to other developers, particularly the sample solution and the tips on how to overcome the issues you have encountered.

Thanks
Steve

Re: Accessing emails on Office 365 via OAuth

PostPosted: Sat Nov 05, 2022 7:35 pm
by nam.le
Dear Robert,
also many thanks from my side to you and all other contribute to this solution.
This is a great help !!
I am still trying to make it work, but it is really good to have you sharing your knowledge.
Best regards and many thanks again
Nam

Re: Accessing emails on Office 365 via OAuth

PostPosted: Tue Nov 15, 2022 7:11 pm
by nam.le
HI Robert,
i just wonder which version of Servoy are you using ?
I use Version: 2021.3.2.3644_LTS and it seems like my plugins.oauth does not have the methods (responseMode and responseType) you use in the example solution.
Best regards
Nam

Re: Accessing emails on Office 365 via OAuth

PostPosted: Tue Nov 15, 2022 9:57 pm
by robert.edelmann
I started the solution on 2022.06, but I think it works at least from 2022.03 onwards.

You could try using
Code: Select all
oauthOffice365.additionalParameters({'response_type':'code'})
oauthOffice365.additionalParameters({'response_mode':'query'})

to manually add the parameters, perhaps that helps.

Re: Accessing emails on Office 365 via OAuth

PostPosted: Sat Nov 19, 2022 10:53 pm
by nam.le
Hi Robert,
thanks for your answer,
I just downloaded the 2202.06 and copy the oauth plugins to my 2201.3.2 installation and could run your test solution now.
I just want to confirm that it is a excellent way of demontrating how things work !!
Appreciate you created and shared it with us !
Best regards
Nam

Re: Accessing emails on Office 365 via OAuth

PostPosted: Tue Jan 17, 2023 4:44 pm
by ionelioras
I tried to use IMAP authentication and I get this error: stackTrace:javax.mail.AuthenticationFailedException: AUTHENTICATE failed
I was able to get a token after I registered the app in Azure. The Graph approach works well, but I could not make IMAP work. Is it still working? Did you have to do some special configuration on the Microsoft account in order to make it work?

Re: Accessing emails on Office 365 via OAuth

PostPosted: Tue Jan 24, 2023 3:23 am
by robert.edelmann
ionelioras wrote:I tried to use IMAP authentication and I get this error: stackTrace:javax.mail.AuthenticationFailedException: AUTHENTICATE failed
I was able to get a token after I registered the app in Azure. The Graph approach works well, but I could not make IMAP work. Is it still working? Did you have to do some special configuration on the Microsoft account in order to make it work?

Sorry, I could only now check the IMAP-Part, we moved to Graph after IMAP gave us reliability issues, some days users could fetch mails, some days they got messages about closed mailboxes.

So yeah, it doesn't work right now, there were general problems on Microsofts side, Thunderbird didn't work due to strange problems with IPv6, I'll keep an eye on it, hopefully I can do some work on this next weekend.

And since I finished some more work on Graph I'll complete some more infos about Folders and delta-tokens to speed up fetching mails via Graph.