-
Content Count
6 -
Joined
-
Last visited
Everything posted by Milo G
-
POP, IMAP and SMPT with OAuth2 (Microsoft Office 365 services)
Milo G posted a topic in Network, Cloud and Web
Hi all, as you probably know Microsoft is disabling basic authentication for Microsoft Office 365 services on October 2022. So we need to find solution for our integrated mail client using OAuth2 protocol that is compatible with Delphi 7. Currently we use Indy 10 SMPT, POP and IMAP client components. Based on this git issue, I assume Indy doesn't have official release jet. Proposed solution is partial in a sense that user is responsible for obtaining the necessary token. We tryed ICS 8.69 mail components and after minor changes, regarding single tenant scenario, we managed to send mail using SMTP client and receive mail using POP3 client. But they use quite a different approach and I don't see IMAP support. If you are ( or were ) facing similar problem, would you share how did you handle change ? Regards, Milo -
too little information ... SQL gets used either way. my shortcut: ctrl+j->mydummy with cdsDUMMY do begin Close; Params.Clear; IndexName := ''; CommandText := ''; Params.ParseSQL(CommandText,True); Params.ParamByName('').AssignFieldValue(); Open; end; depends on architecture - maybe apply latter 🙂 regards
-
I am no expert and use them both. It's good to have Free Pascal with Lazarus as an free option, it's Object Pascal syntax that works. Compared to Delphi they lack component support - as you probably now. Regards
-
Hi all, I know that Delphi 7 is old version, that most of you don't use anymore. Based on your samples, we have implemented receving emails over POP3 ( MS OAuth2 ) using your TSslPop3Cli, TSslContext and TIcsRestEmail components. It works fine in runtime, user authenticates and we recive emails. But it seems that component somehow brakes debugger ( Windows 10 ). We have used your components in the past and previous version was 8.58 - I have renamed old folder so it souldn't interfere. If I remove new form (unit) that uses 8.69 components debugger works. Our program consists of dlls that get loaded from main exe program, dlls contain datamodule and forms. Do you have any idea how to solve it ? Or what to look for ... We get "External exception C0000029" in ntdll.dll and Delphi must be restarted, below is call stack if it helps ... Regards Milo Call Stack Information: ------------------------------------------------------------------------------------------- |Address |Module |Unit |Class |Procedure/Method |Line| ------------------------------------------------------------------------------------------- | Running Thread: ID=9496; Priority=0; Class=; [Main] | |-----------------------------------------------------------------------------------------| |40006E20|rtl70.bpl |System.pas | |_LStrClr | | |77798BC0|ntdll.dll | | |RtlRaiseException | | |40003410|rtl70.bpl |System.pas | |_GetMem | | |769D05C0|KERNEL32.DLL | | |RtlUnwind | | |02B86B44|dcc70.dll | | |LookupProc | | |768EFC40|ucrtbase.dll | | |memcpy | | |02B880B8|dcc70.dll | | |GetNearestSymName | | |769CE7E0|KERNEL32.DLL | | |InterlockedIncrement | | |7774E760|ntdll.dll | | |RtlLeaveCriticalSection| | |769CE860|KERNEL32.DLL | | |InterlockedDecrement | | |40006E44|rtl70.bpl |System.pas | |_LStrArrayClr | | |02757EF8|vclide70.bpl |Discomp.pas |TDisassemblerView |DisassembleAt | | |400095F0|rtl70.bpl |System.pas | |_IntfClear | | |0236F328|coreide70.bpl|Comdebug.pas| |FindSourceLine | | |0275D570|vclide70.bpl |Discomp.pas | |MakeCPUSourcePos | | |027588A0|vclide70.bpl |Discomp.pas |TDisassemblerView |DrawLine | | |025F5E84|vcl70.bpl |Graphics.pas|TFont |SetColor | | |025F59E0|vcl70.bpl |Graphics.pas|TGraphicsObject |Unlock | | |02758398|vclide70.bpl |Discomp.pas |TDisassemblerView |IterateAddrs | | |02674DE0|vcl70.bpl |Controls.pas|TWinControl |PaintHandler | | |0267531C|vcl70.bpl |Controls.pas|TWinControl |WMPaint | | |02671910|vcl70.bpl |Controls.pas|TControl |WndProc | | |026C06A0|vcl70.bpl |Appevnts.pas|TCustomApplicationEvents|DoMessage | | |02695608|vcl70.bpl |Forms.pas |TApplication |ProcessMessage | | |026956A0|vcl70.bpl |Forms.pas |TApplication |ProcessMessages | | |026C059C|vcl70.bpl |Appevnts.pas|TCustomApplicationEvents|DoActivate | | |02695608|vcl70.bpl |Forms.pas |TApplication |ProcessMessage | | |026956A0|vcl70.bpl |Forms.pas |TApplication |ProcessMessages | | |026C059C|vcl70.bpl |Appevnts.pas|TCustomApplicationEvents|DoActivate | | |02695608|vcl70.bpl |Forms.pas |TApplication |ProcessMessage | | |026956A0|vcl70.bpl |Forms.pas |TApplication |ProcessMessages | | |026C059C|vcl70.bpl |Appevnts.pas|TCustomApplicationEvents|DoActivate | | |4002F620|rtl70.bpl |Classes.pas |TList |Get | | |40046B68|rtl70.bpl |Contnrs.pas |TComponentList |GetItems | | |026C06A0|vcl70.bpl |Appevnts.pas|TCustomApplicationEvents|DoMessage | | |760C7DB0|USER32.dll | | |DispatchMessageA | | |02695608|vcl70.bpl |Forms.pas |TApplication |ProcessMessage | | |026956B8|vcl70.bpl |Forms.pas |TApplication |HandleMessage | | |0269585C|vcl70.bpl |Forms.pas |TApplication |Run | |
-
Yes problem was at mine side, it works now and I can debugg again. I had to re-install component: remove package, add it back and refresh runtime packages. Strange thing is that I could debug exe but not dll (exception on module load). Anyhow it's solved now. Thank you !
-
POP, IMAP and SMPT with OAuth2 (Microsoft Office 365 services)
Milo G replied to Milo G's topic in Network, Cloud and Web
Thank you all for quick response. I didn't know that Delphi community is so vibrant - kudos ! As I wrote, it was a minor ad-hoc change ... maybe you could find a better place in code for fix. Login (CAppUrl) and token (CTokenUrl) endpoint must include Tenant ID insted of "consumers" or "common" (which Thunderbird use) -> https://login.microsoftonline.com/{tenant}/v2.0/. I added TenantID property next to FCliID in TIcsRestEmail class and string replace in CommonSettings function for type RestEmailMSRest or RestEmailMSSmtp: " if (FTenantID <> '') then begin FRestOAuth.FAppUrl := StringReplace(FRestOAuth.FAppUrl,'consumers',FTenantID,[rfReplaceAll, rfIgnoreCase]); FRestOAuth.FTokenUrl := StringReplace(FRestOAuth.FTokenUrl,'consumers',FTenantID,[rfReplaceAll, rfIgnoreCase]); end; " You could also expose RedirectURL part of login endpoint, because MS service returns error, if it's not the same as registrated in Azure AD. I get that, it's general solution. But from user stand point it's quite complicated and each of us have to implement it. There are few major playes regarding mailing service, so it would be nice to have common solution for key players. In my case, regarding Microsoft service, is a metter of setting scope parameter when requesting token. If POP then "https://outlook.office.com/POP.AccessAsUser.All" if SMTP "https://outlook.office.com/SMTP.Send" if IMAP "https://outlook.office.com/IMAP.AccessAsUser.All" Or even better property where you can select all 🙂 along with commons like "offline_access" and "https://outlook.office.com/MailboxSettings.Read" for reading user profile. I have couple of days to decide and will try out suggested sasl-oauth branch using ICS solution (web server redirect to localhost). Thank you for you pointer on Microsoft Graph is a viable option.