See the version list below for details.
dotnet add package GoogleAuthenticator --version 3.1.0
NuGet\Install-Package GoogleAuthenticator -Version 3.1.0
<PackageReference Include="GoogleAuthenticator" Version="3.1.0" />
paket add GoogleAuthenticator --version 3.1.0
#r "nuget: GoogleAuthenticator, 3.1.0"
// Install GoogleAuthenticator as a Cake Addin #addin nuget:?package=GoogleAuthenticator&version=3.1.0 // Install GoogleAuthenticator as a Cake Tool #tool nuget:?package=GoogleAuthenticator&version=3.1.0
Simple, easy to use server-side two-factor authentication library for .NET that works with Google Authenticator
key should be stored by your application for future authentication and shouldn't be regenerated for each request. The process of storing the private key is outside the scope of this library and is the responsibility of the application.
using Google.Authenticator; string key; TwoFactorAuthenticator tfa = new TwoFactorAuthenticator(); SetupCode setupInfo = tfa.GenerateSetupCode("Test Two Factor", "email@example.com", key, false, 3); string qrCodeImageUrl = setupInfo.QrCodeSetupImageUrl; string manualEntrySetupCode = setupInfo.ManualEntryKey; imgQrCode.ImageUrl = qrCodeImageUrl; lblManualSetupCode.Text = manualEntrySetupCode; // verify TwoFactorAuthenticator tfa = new TwoFactorAuthenticator(); bool result = tfa.ValidateTwoFactorPIN(key, txtCode.Text)
- Removed support for legacy .Net Framework. Lowest supported versions are now netstandard2.0 and .Net 4.6.2.
- All use of System.Drawing has been removed. In 2.5, only Net 6.0 avoided System.Drawing.
- Linux installations no longer need to ensure
libgdiplusis installed as it is no longer used.
- Changed from using
EscapeDataStringto encode the "account title" as the former is obsolete in .Net 6. This changes the value in the generated data string from
a%40b.com. We have tested this with Google Authenticator, Lastpass Authenticator and Microsoft Authenticator. All three of them handle it correctly and all three recognise that it is still the same account so this should be safe in most cases.
Now runs on .Net 6.0.
Technically the QR Coder library we rely on still does not fully support .Net 6.0 so it is possible there will be other niggling issues, but for now all tests pass for .Net 6.0 on both Windows and Linux.
- Old documentation indicated specifying width and height for the QR code, but changes in QR generation now uses pixels per module (QR "pixel") so using a value too high will result in a huge image that can overrun memory allocations
- Don't use the secret key and
ManualEntryKeyis used to enter into the authenticator app when scanning a QR code is impossible and is derived from the secret key (discussion example)
- With versions prior to 3.0 only, on linux, you need to ensure
libgdiplusis installed if you want to generate QR Codes. See https://github.com/codebude/QRCoder/issues/227.
|Product||Versions Compatible and additional computed target framework versions.|
|.NET||net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed.|
|.NET Core||netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed.|
|.NET Standard||netstandard2.0 is compatible. netstandard2.1 was computed.|
|.NET Framework||net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed.|
|MonoAndroid||monoandroid was computed.|
|MonoMac||monomac was computed.|
|MonoTouch||monotouch was computed.|
|Tizen||tizen40 was computed. tizen60 was computed.|
|Xamarin.iOS||xamarinios was computed.|
|Xamarin.Mac||xamarinmac was computed.|
|Xamarin.TVOS||xamarintvos was computed.|
|Xamarin.WatchOS||xamarinwatchos was computed.|
NuGet packages (25)
Showing the top 5 NuGet packages that depend on GoogleAuthenticator:
Geeks Core Library
Content Repository layer for the sensenet platform.
Integration with Google MFA
Custom extension for Google Authenticator
GitHub repositories (6)
Showing the top 5 popular GitHub repositories that depend on GoogleAuthenticator:
ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
Free open source office suite with business productivity tools: document and project management, CRM, mail aggregator.
Open source, headless, multi-tenant eCommerce platform built with .NET Core, MongoDB, AWS DocumentDB, Azure CosmosDB, Vue.js.
Open-Source eCommerce Platform on .NET Core, MongoDB, AWS DocumentDB, Azure CosmosDB, LiteDB & Vue.js
Open Source Content Services Platform written in .NET