Ling.Blazor.Authentication 0.0.4

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

// Install Ling.Blazor.Authentication as a Cake Tool
#tool nuget:?package=Ling.Blazor.Authentication&version=0.0.4

Introduction

Ling.Blazor.Authentication is a library that provides JWT authentication for Blazor applications.

Installation

  1. Package Manager

You can install this library using either Package Manager or .NET CLI.

PM> Install-Package Ling.Blazor.Authentication
  1. .NET CLI
dotnet add package Ling.Blazor.Authentication

Usage

To use this library, you need to follow these steps:

  1. Implement your own JwtAuthenticationService class that inherits from JwtAuthenticationServiceBase class. For example:
public class JwtAuthenticationService : JwtAuthenticationServiceBase
{
    public AuthenticationService(IServiceProvider serviceProvider) : base(serviceProvider)
    {
    }

    public Task LoginAsync(string username, string password, bool isPersistent = false, CancellationToken cancellationToken = default)
    {
       // Write your login logic here and get the tokenInfo object

       // Remember to call 'SetTokenAsync' to save the tokenInfo
       await SetTokenAsync(tokenInfo, cancellationToken);
    }
}
  1. Register the services in Program.cs file. For example:
builder.Services.AddJwtAuthorization<JwtAuthenticationService>(); // You can configure 'JwtAuthOptions' here if needed

builder.Services.AddServerAPI(baseAddress); // Replace baseAddress with your actual API server address

The AddServerAPI method will register an HttpClient for you, which will automatically set the Authorization header for your requests.

Product Compatible and additional computed target framework versions.
.NET 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 is compatible.  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. 
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
0.0.4 135 5/13/2023
0.0.3 105 5/13/2023