Accessing emails on Office 365 via OAuth

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Re: Accessing emails on Office 365 via OAuth

Postby robert.edelmann » Tue Oct 11, 2022 11:09 am

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
mit freundlichen Grüßen
Robert Stefan Edelmann
User avatar
robert.edelmann
 
Posts: 91
Joined: Wed Aug 14, 2013 6:12 pm

Re: Accessing emails on Office 365 via OAuth

Postby robert.edelmann » Tue Oct 18, 2022 4:02 pm

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.
mit freundlichen Grüßen
Robert Stefan Edelmann
User avatar
robert.edelmann
 
Posts: 91
Joined: Wed Aug 14, 2013 6:12 pm

Re: Accessing emails on Office 365 via OAuth

Postby steve1376656734 » Wed Oct 19, 2022 10:00 am

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
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 327
Joined: Fri Aug 16, 2013 2:38 pm
Location: Ashford, UK

Re: Accessing emails on Office 365 via OAuth

Postby nam.le » Sat Nov 05, 2022 7:35 pm

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
nam.le
 
Posts: 22
Joined: Thu Jan 21, 2021 1:32 pm

Re: Accessing emails on Office 365 via OAuth

Postby nam.le » Tue Nov 15, 2022 7:11 pm

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
nam.le
 
Posts: 22
Joined: Thu Jan 21, 2021 1:32 pm

Re: Accessing emails on Office 365 via OAuth

Postby robert.edelmann » Tue Nov 15, 2022 9:57 pm

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.
mit freundlichen Grüßen
Robert Stefan Edelmann
User avatar
robert.edelmann
 
Posts: 91
Joined: Wed Aug 14, 2013 6:12 pm

Re: Accessing emails on Office 365 via OAuth

Postby nam.le » Sat Nov 19, 2022 10:53 pm

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
nam.le
 
Posts: 22
Joined: Thu Jan 21, 2021 1:32 pm

Re: Accessing emails on Office 365 via OAuth

Postby ionelioras » Tue Jan 17, 2023 4:44 pm

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?
Ionel Ioras
Stb Software Development
SAN Partner

Stb Software Development - http://www.stb-development.com
User avatar
ionelioras
 
Posts: 37
Joined: Mon Jun 01, 2009 9:49 am
Location: Timisoara, Romania

Re: Accessing emails on Office 365 via OAuth

Postby robert.edelmann » Tue Jan 24, 2023 3:23 am

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.
mit freundlichen Grüßen
Robert Stefan Edelmann
User avatar
robert.edelmann
 
Posts: 91
Joined: Wed Aug 14, 2013 6:12 pm

Previous

Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 8 guests