Rystem.Authentication.Social.Abstractions 10.0.3

dotnet add package Rystem.Authentication.Social.Abstractions --version 10.0.3
                    
NuGet\Install-Package Rystem.Authentication.Social.Abstractions -Version 10.0.3
                    
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="Rystem.Authentication.Social.Abstractions" Version="10.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rystem.Authentication.Social.Abstractions" Version="10.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Rystem.Authentication.Social.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Rystem.Authentication.Social.Abstractions --version 10.0.3
                    
#r "nuget: Rystem.Authentication.Social.Abstractions, 10.0.3"
                    
#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.
#:package Rystem.Authentication.Social.Abstractions@10.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Rystem.Authentication.Social.Abstractions&version=10.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Rystem.Authentication.Social.Abstractions&version=10.0.3
                    
Install as a Cake Tool

What is Rystem?

Rystem.Authentication.Social.Abstractions

Shared models, interfaces, and abstractions for Rystem social authentication libraries.

📦 Installation

dotnet add package Rystem.Authentication.Social.Abstractions

🔑 Core Interfaces

ISocialUser

Base interface for social user models:

public interface ISocialUser
{
    string? Username { get; set; }
}

DefaultSocialUser

Default implementation provided by the library:

internal sealed class DefaultSocialUser : ISocialUser
{
    public string? Username { get; set; }
}

Custom Social User

Extend with your application-specific properties:

public sealed class CustomSocialUser : ISocialUser
{
    public string? Username { get; set; }
    public string DisplayName { get; set; }
    public string Email { get; set; }
    public Guid UserId { get; set; }
    public string Avatar { get; set; }
    public List<string> Roles { get; set; } = new();
    public DateTime CreatedAt { get; set; }
    public DateTime LastLogin { get; set; }
}

🔐 TokenCheckerSettings

Unified settings class for OAuth token validation (with PKCE support):

public sealed class TokenCheckerSettings
{
    /// <summary>
    /// Domain for OAuth redirect (e.g., https://yourdomain.com)
    /// </summary>
    public string? Domain { get; set; }

    /// <summary>
    /// Redirect path after OAuth callback (default: /)
    /// Used to construct full redirect_uri: {Domain}{RedirectPath}
    /// </summary>
    public string RedirectPath { get; set; } = "/";

    /// <summary>
    /// Additional parameters for token exchange
    /// Example: { "code_verifier": "abc123..." } for PKCE
    /// </summary>
    public Dictionary<string, string>? AdditionalParameters { get; set; }

    /// <summary>
    /// Get full redirect URI by combining Domain and RedirectPath
    /// </summary>
    public string GetRedirectUri()
    {
        if (string.IsNullOrWhiteSpace(Domain))
            return RedirectPath;

        return $"{Domain.TrimEnd('/')}{RedirectPath}";
    }

    /// <summary>
    /// Get additional parameter by key (e.g., "code_verifier")
    /// </summary>
    public string? GetParameter(string key)
    {
        if (AdditionalParameters == null || string.IsNullOrWhiteSpace(key))
            return null;

        return AdditionalParameters.TryGetValue(key, out var value) ? value : null;
    }

    /// <summary>
    /// Set additional parameter (fluent API)
    /// </summary>
    public TokenCheckerSettings WithParameter(string key, string value)
    {
        AdditionalParameters ??= new Dictionary<string, string>();
        AdditionalParameters[key] = value;
        return this;
    }
}

Usage Examples

Basic Usage
var settings = new TokenCheckerSettings
{
    Domain = "https://yourdomain.com",
    RedirectPath = "/account/login"
};

var fullUri = settings.GetRedirectUri();  // "https://yourdomain.com/account/login"
With PKCE (Microsoft OAuth)
var settings = new TokenCheckerSettings
{
    Domain = "https://yourdomain.com",
    RedirectPath = "/account/login",
    AdditionalParameters = new Dictionary<string, string>
    {
        { "code_verifier", "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk" }
    }
};

var codeVerifier = settings.GetParameter("code_verifier");
Fluent API
var settings = new TokenCheckerSettings
    .WithParameter("code_verifier", codeVerifier)
    .WithParameter("custom_param", "value");

📝 TokenResponse

Response from OAuth token validation:

public sealed class TokenResponse
{
    /// <summary>
    /// Username/email from OAuth provider
    /// </summary>
    public required string Username { get; init; }
    
    /// <summary>
    /// Claims extracted from OAuth provider
    /// </summary>
    public required List<Claim> Claims { get; init; }
    
    /// <summary>
    /// Empty response for failed validations
    /// </summary>
    public static TokenResponse Empty => new TokenResponse 
    { 
        Username = string.Empty, 
        Claims = new List<Claim>() 
    };
}

🌐 ProviderType Enum

Supported OAuth providers:

public enum ProviderType
{
    DotNet = 0,      // Internal .NET bearer token
    Microsoft = 1,   // Microsoft Entra ID (Azure AD)
    Google = 2,      // Google OAuth
    Facebook = 3,    // Facebook Login
    GitHub = 4,      // GitHub OAuth
    Amazon = 5,      // Amazon Login
    Linkedin = 6,    // LinkedIn OAuth
    X = 7,           // X (Twitter) OAuth
    TikTok = 8,      // TikTok Login
    Instagram = 9,   // Instagram Basic Display
    Pinterest = 10   // Pinterest OAuth
}

🔧 ITokenChecker Interface

Core interface for OAuth token validation:

public interface ITokenChecker
{
    /// <summary>
    /// Validate OAuth authorization code and exchange for user information
    /// </summary>
    /// <param name="code">Authorization code from OAuth provider</param>
    /// <param name="settings">Token checker settings (domain, redirectPath, code_verifier, etc.)</param>
    /// <param name="cancellationToken">Cancellation token</param>
    /// <returns>TokenResponse with username and claims, or error message</returns>
    Task<AnyOf<TokenResponse?, string>> CheckTokenAndGetUsernameAsync(
        string code, 
        TokenCheckerSettings settings, 
        CancellationToken cancellationToken = default);
}

Implementation Example

public class CustomTokenChecker : ITokenChecker
{
    private readonly IHttpClientFactory _httpClientFactory;
    private readonly CustomOAuthSettings _settings;
    
    public CustomTokenChecker(
        IHttpClientFactory httpClientFactory, 
        CustomOAuthSettings settings)
    {
        _httpClientFactory = httpClientFactory;
        _settings = settings;
    }
    
    public async Task<AnyOf<TokenResponse?, string>> CheckTokenAndGetUsernameAsync(
        string code, 
        TokenCheckerSettings settings, 
        CancellationToken cancellationToken)
    {
        var codeVerifier = settings.GetParameter("code_verifier");
        var redirectUri = settings.GetRedirectUri();
        
        var client = _httpClientFactory.CreateClient("CustomOAuth");
        
        var tokenRequest = new Dictionary<string, string>
        {
            ["code"] = code,
            ["client_id"] = _settings.ClientId,
            ["client_secret"] = _settings.ClientSecret,
            ["redirect_uri"] = redirectUri,
            ["grant_type"] = "authorization_code"
        };
        
        // Add PKCE if provided
        if (!string.IsNullOrWhiteSpace(codeVerifier))
        {
            tokenRequest["code_verifier"] = codeVerifier;
        }
        
        var response = await client.PostAsync(
            "https://oauth.provider.com/token",
            new FormUrlEncodedContent(tokenRequest),
            cancellationToken);
        
        if (!response.IsSuccessStatusCode)
        {
            var error = await response.Content.ReadAsStringAsync(cancellationToken);
            return error;
        }
        
        var tokenData = await response.Content.ReadFromJsonAsync<OAuthTokenResponse>(cancellationToken);
        
        // Validate ID token and extract claims
        var claims = ExtractClaims(tokenData.IdToken);
        var username = claims.FirstOrDefault(c => c.Type == ClaimTypes.Email)?.Value;
        
        return new TokenResponse
        {
            Username = username ?? string.Empty,
            Claims = claims
        };
    }
}
  • Server Implementation: Rystem.Authentication.Social - ASP.NET Core OAuth endpoints
  • Blazor Client: Rystem.Authentication.Social.Blazor - Blazor UI components
  • React Client: rystem.authentication.social.react - React/TypeScript hooks

📚 More Information

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Rystem.Authentication.Social.Abstractions:

Package Downloads
Rystem.Authentication.Social

Rystem.Authentication.Social helps you to integrate with new .Net Identity system and social logins.

Rystem.Authentication.Social.Blazor

Rystem.Authentication.Social helps you to integrate with new .Net Identity system and social logins.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.3 93 1/28/2026
10.0.1 173,877 11/12/2025
9.1.3 407 9/2/2025
9.1.2 764,571 5/29/2025
9.1.1 97,849 5/2/2025
9.0.32 186,612 4/15/2025
9.0.31 5,867 4/2/2025
9.0.30 88,802 3/26/2025
9.0.29 9,040 3/18/2025
9.0.28 253 3/17/2025
9.0.27 251 3/16/2025
9.0.26 293 3/13/2025
9.0.25 52,172 3/9/2025
9.0.23 197 3/9/2025
9.0.21 378 3/6/2025
9.0.20 19,556 3/6/2025
9.0.19 333 3/6/2025
9.0.18 333 3/4/2025
9.0.17 210 3/1/2025
9.0.16 194 3/1/2025
9.0.15 75,553 2/22/2025
9.0.14 22,584 2/18/2025
9.0.13 196 2/9/2025
9.0.12 217,754 1/13/2025
9.0.11 24,047 1/9/2025
9.0.10 170 1/9/2025
9.0.9 4,060 1/7/2025
9.0.8 12,572 1/6/2025
9.0.7 190 1/6/2025
9.0.5 148 12/30/2024
9.0.4 92,317 12/23/2024
9.0.3 186 12/22/2024
9.0.2 10,722 12/21/2024
9.0.1 1,238 12/21/2024
9.0.0 173,176 11/16/2024
9.0.0-rc.1 147 10/18/2024
6.2.0 219,157 10/9/2024
6.1.1 215 10/9/2024
6.1.0 48,046 9/29/2024
6.0.24 260 9/11/2024
6.0.23 340,305 7/18/2024
6.0.21 340,222 6/18/2024
6.0.20 727,740 6/16/2024
6.0.19 30,462 6/14/2024
6.0.18 210 6/14/2024
6.0.17 216 6/14/2024
6.0.16 50,056 6/10/2024
6.0.15 220 6/9/2024
6.0.14 94,369 5/24/2024
6.0.13 217 5/23/2024
6.0.12 205 5/23/2024
6.0.11 243 5/20/2024
6.0.9 256 5/19/2024
6.0.7 173 5/19/2024