GoogleAuthenticator.MutlipleQRCoder
2.5.0
See the version list below for details.
dotnet add package GoogleAuthenticator.MutlipleQRCoder --version 2.5.0
NuGet\Install-Package GoogleAuthenticator.MutlipleQRCoder -Version 2.5.0
<PackageReference Include="GoogleAuthenticator.MutlipleQRCoder" Version="2.5.0" />
paket add GoogleAuthenticator.MutlipleQRCoder --version 2.5.0
#r "nuget: GoogleAuthenticator.MutlipleQRCoder, 2.5.0"
// Install GoogleAuthenticator.MutlipleQRCoder as a Cake Addin #addin nuget:?package=GoogleAuthenticator.MutlipleQRCoder&version=2.5.0 // Install GoogleAuthenticator.MutlipleQRCoder as a Cake Tool #tool nuget:?package=GoogleAuthenticator.MutlipleQRCoder&version=2.5.0
GoogleAuthenticator
Simple, easy to use server-side two-factor authentication library for .NET that works with Google Authenticator
Install-Package GoogleAuthenticator
1.x Usage
See blog post for usage instructions (1.x only):
2.x Usage
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", "user@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)
Updates
2.5.0
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)
Notes
On linux, you need to ensure libgdiplus
is 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 is compatible. 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. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | 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 | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.6.2
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.