VNS.MitID 4.0.0

dotnet add package VNS.MitID --version 4.0.0
NuGet\Install-Package VNS.MitID -Version 4.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="VNS.MitID" Version="4.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VNS.MitID --version 4.0.0
#r "nuget: VNS.MitID, 4.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 VNS.MitID as a Cake Addin
#addin nuget:?package=VNS.MitID&version=4.0.0

// Install VNS.MitID as a Cake Tool
#tool nuget:?package=VNS.MitID&version=4.0.0

VNS MitID

Simple integration to Nets and Criipto MitID

Installation

Use the package manager nuget to install.

dotnet add package VNS.MitID

Usage

string _authorityUrl = "";
string _clientId = "";
string _clientSecret = "";
string _redirectUrl = "";

// Init and load discovery info
var mitId = new MitID(_authorityUrl, _clientId, _clientSecret, _redirectUrl);

// Set to true if you want to force a login
// OBS. Only Nets
bool mitId.ForceLogin;

// Set to true if MitID Erhverv should be able to log in
bool mitId.EnableBusiness;

// Set to false if MitID Erhverv should only allow business logins
// OBS. Only Nets
bool mitId.AllowPrivateOnBusiness;

// Set to true if the user should have the option to choose between MitID and MitID Erhverv at log in
// OBS. Only Nets
// OBS. Will only work if EnableBusiness is true
bool mitId.EnableLoginOption;

// Returns a login url
Console.WriteLine(mitId.GetLoginUrl());

var _code = ""; // This code will be returned in the querystring to the redirectUrl

// Get the diffrent tokens
var tokens = mitId.GetTokens(_code);
Console.WriteLine(tokens.Id);
Console.WriteLine(tokens.Access);
Console.WriteLine(tokens.Userinfo); // This is only available with Nets
Console.WriteLine(tokens.ToString()); // Will return the RAW json result

// Get users info
var user = mitId.GetUserInfo(tokens);
Console.WriteLine(user.IsBusiness);
Console.WriteLine(user.Id);
Console.WriteLine(user.SSN);
Console.WriteLine(user.Name);
Console.WriteLine(user.Email); // This is only available with MitID Erhverv
Console.WriteLine(user.Company); // This is only available with MitID Erhverv
Console.WriteLine(user.CVR); // This is only available with MitID Erhverv
Console.WriteLine(user.Age);
Console.WriteLine(user.Birthday);
Console.WriteLine(user.ToString()); // Will return the RAW json result

// Returns a logout url
// OBS. Remember to kill any sessions you have made with user object etc.
Console.WriteLine(mitId.GetLogoutUrl(user, "https://domain.com/you_are_now_logged_out.html"));

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.0 121 12/14/2023
3.0.0 103 12/14/2023
1.0.9 125 10/4/2023
1.0.8 285 1/3/2023