OAuth 2.0 in Windows, .NET Core, and ASP.NET MVC apps

You can use MailBee.NET Objects to check and send mail via OAuth 2.0 with Google and Microsoft providers including Gmail, Office 365, Outlook.com, Live.com, Hotmail.com. In the future, if more providers implement XOAUTH2 extension in their IMAP and SMTP protocols, they will be supported as well.

This guide reflects the state third-party services (Google, Microsoft, etc) at the moment of writing. Developer consoles are updated by their vendors quite often so the screenshots in this guide may not reflect the current state of the corresponding services. Still, the common approach will basically remain the same.

OAuth 2.0 is a complex topic, and this tutorial aims to address as many concerns as possible, including:

ASP.NET, desktop and console the samples are available for both C# and VB and target .NET Framework v4.5 or newer.

.NET Core samples target ASP.NET Core 2.0 (web) and .NET Core 2.0 (console), available in C# version only. Tested with .NET Core 2.2 as well.

Office 365 samples have two versions - Credentials Flow (non-interactive) and Authorization Code Flow (interactive, the user must grant access to your app on the consent screen). Authorization Code Flow version requires ASP.NET Core 3.1 at least.

ASP.NET samples require Visual Studio 2013 Update 3 or newer (they are using the latest version of ASP.NET MVC template, MVC5 at the moment of writing).

ASP.NET Core 2.0 sample was developed with Visual Studio 2017 15.9. ASP.NET Core 3.1 Office 365 version requires Visual Studio 2019 (again, this is only for interactive case, if you need non-interactive Credentials Flow version, see Office 365 accounts for installed non-interactive applications).

Installed applications for .NET Framework (console and WinForms samples) require Visual Studio 2012 at least.

Please select the article which corresponds your case:

All C# and VB samples discussed in this tutorial are shipped with MailBee.NET Objects installer and get installed into My Documents\MailBee.NET Objects\Samples folder.

ASP.NET and ASP.NET Core samples:

WinForms and console samples for .NET Framework 4.5 or newer, .NET Core 2.0 or newer, Universal Windows (Windows 10 Fall Creators Update or newer):

Samples\WinForms.NET 4.5 OAuth\C#\ReadAspNetUsers and Samples\WinForms\.NET Core 2.0\C#\ReadAspNetUsers apps are special in that they are console but work with the same users database as ASP.NET/ASP.NET Core samples and demonstrate how web and non-web OAuth apps can interoperate.


Send feedback to AfterLogic

Copyright © 2006-2023 AfterLogic Corporation. All rights reserved.