GoogleAuthenticator 3.0.0

.NET Standard 2.0 .NET Framework 4.6.2
dotnet add package GoogleAuthenticator --version 3.0.0
NuGet\Install-Package GoogleAuthenticator -Version 3.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GoogleAuthenticator" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GoogleAuthenticator --version 3.0.0
#r "nuget: GoogleAuthenticator, 3.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install GoogleAuthenticator as a Cake Addin
#addin nuget:?package=GoogleAuthenticator&version=3.0.0

// Install GoogleAuthenticator as a Cake Tool
#tool nuget:?package=GoogleAuthenticator&version=3.0.0


Simple, easy to use server-side two-factor authentication library for .NET that works with Google Authenticator

Build Status NuGet Status

Install-Package GoogleAuthenticator


Additional examples at Google.Authenticator.WinTest and Google.Authenticator.WebSample

using Google.Authenticator;

string key = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);

TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
SetupCode setupInfo = tfa.GenerateSetupCode("Test Two Factor", "", 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)

Update history


  • 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 libgdiplus is installed as it is no longer used.
  • Changed from using EscapeUriString to EscapeDataString to encode the "account title" as the former is obsolete in .Net 6. This changes the value in the generated data string from to 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.

Common Pitfalls

  • 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 ManualEntryKey interchangeably. ManualEntryKey is 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 libgdiplus is installed if you want to generate QR Codes. See
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.2

  • .NETStandard 2.0

NuGet packages (26)

Showing the top 5 NuGet packages that depend on GoogleAuthenticator:

Package Downloads

Integration with Google MFA


Geeks Core Library


Package Description


Custom extension for Google Authenticator



GitHub repositories (5)

Showing the top 5 popular GitHub repositories that depend on GoogleAuthenticator:

Repository Stars
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.
Free, Open source, Fast, Headless, Multi-tenant eCommerce platform built with .NET Core, MongoDB, AWS DocumentDB, Azure CosmosDB, LiteDB, Vue.js.
Platform for creating your own online office.
Version Downloads Last updated
3.0.0 287,033 6/1/2022
3.0.0-beta2 298 5/26/2022
3.0.0-beta1 626 5/6/2022
2.5.0 81,678 4/13/2022
2.4.0 120,145 12/28/2021
2.3.0 69,639 11/30/2021
2.2.0 253,958 7/13/2021
2.1.1 366,644 12/3/2020
2.0.1 331,577 1/10/2020
2.0.0 7,700 1/2/2020
1.2.1 1,056,093 12/7/2016
1.2.0 79,256 9/23/2015
1.1.0 6,105 1/7/2015
1.0.0 1,876 9/8/2014