Recent

Author Topic: Oauth in synapse  (Read 638 times)

el3ctrolyte

  • New Member
  • *
  • Posts: 13
Oauth in synapse
« on: July 30, 2020, 09:41:58 am »
I want to send emails with my program using synapse's smtpsend library but i ran into a problem. When i try to send the email to gmail account then the email send fails. I found that if i go to the specified email's account settings and disable the security features then the email send works. After some research i found that the culprit is 0Auth and that synapse doesn't implement 0Auth. I want to know how i can add 0auth authentication so that i can send emails without having to disable the security features option in the email account. I know that i can use the googleapis library, but i want my program to work with any email account not just gmail accounts. So can someone please help me?

PascalDragon

  • Hero Member
  • *****
  • Posts: 2138
  • Compiler Developer
Re: Oauth in synapse
« Reply #1 on: July 30, 2020, 10:16:39 am »
You should read up on how OAuth2 is handled for SMTP by Google (for example here). With that you might be able to use fpWeb's fpOAuth2 unit to handle the gritty part. For this you could also check how the TGoogleClient class is handling this as it uses fpOAuth2 as well (even if you aren't using the Google API it might help you).

Leledumbo

  • Hero Member
  • *****
  • Posts: 8266
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Oauth in synapse
« Reply #2 on: July 30, 2020, 12:00:48 pm »
Use the loopback ip address mechanism: https://developers.google.com/identity/protocols/oauth2/native-app
This is the one that gcloud tools use (basically run a wbe server listening on a local port, open a browser with the oauth request setting redirect uri to the local web server). Alternatively, the manual copy/paste can also be done but less convenient.

jus

  • New Member
  • *
  • Posts: 21
Re: Oauth in synapse
« Reply #3 on: July 30, 2020, 02:03:33 pm »
Hi, just take a look on the \lazarus\components\googleapis\demo samples. I think there is/was an option to use the synapse component instead. In the demos are oauth implementation as PascalDragon mentioned.

And I uploaded a Google SpreadSheet Demo for Delphi 2007 with the Synapse component in the german Delphipraxisforum. I think it should be easy to convert it to Lazarus.
« Last Edit: July 30, 2020, 04:33:51 pm by jus »

el3ctrolyte

  • New Member
  • *
  • Posts: 13
Re: Oauth in synapse
« Reply #4 on: July 31, 2020, 12:36:47 am »
Is there any documentation for the fpoauth2 library? I can't seem to find it in the wiki(if it is there).

Thaddy

  • Hero Member
  • *****
  • Posts: 10482
Re: Oauth in synapse
« Reply #5 on: July 31, 2020, 07:49:09 am »
There is an example here: packages/googleapi/examples/calendar/calendardemo.lpr
When you ask a question that is actually answered in the documentation, you are either lazy or a moron.

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 814
    • Lebeau Software
Re: Oauth in synapse
« Reply #6 on: August 03, 2020, 09:26:39 pm »
I found that if i go to the specified email's account settings and disable the security features then the email send works.

You don't need to disable security.  For example, if MFA is enabled, you can generate an App Password, which can be used in software that doesn't support OAuth.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018