Connect your mail transporters with an OAuth 2.0 token

Lately, email servers on the web have started to move to OAuth 2.0 authentication to increase security. Starting with 4D v18 R6, 4D provides a way to set the OAuth 2.0 authentication mode of a connection. Keep reading for the details!

HDI OAuth2 connection

IMAP, SMTP, and POP3 transporters now natively support OAuth 2.0 authentication. The OAuth 2.0 protocol is used to obtain an access token that allows you access to your emails. To use it, you just need to create your transporter as usual and replace the password attribute with the new accessTokenOAuth2 attribute, then add your token there.

For example, to create an IMAP transporter with OAuth 2.0:

$parameters:=New object
$parameters.authenticationMode:=IMAP authentication OAUTH2
// Token received from the web mail server
$parameters.accessTokenOAuth2:=$token
// e-mail address of the user for whom the token was created
$parameters.user:=$user
$parameters.host:="Outlook.office365.com"
$parameters.port:=995
$imapTransporter:=IMAP New transporter($parameters)

Download the HDI above to see OAuth 2.0 authentication in action by connecting your Gmail account!

And check out the doc center for more details!

 

Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.