Rystem.Authentication.Social.Abstractions 9.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Rystem.Authentication.Social.Abstractions --version 9.0.2                
NuGet\Install-Package Rystem.Authentication.Social.Abstractions -Version 9.0.2                
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="9.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rystem.Authentication.Social.Abstractions --version 9.0.2                
#r "nuget: Rystem.Authentication.Social.Abstractions, 9.0.2"                
#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 Rystem.Authentication.Social.Abstractions as a Cake Addin
#addin nuget:?package=Rystem.Authentication.Social.Abstractions&version=9.0.2

// Install Rystem.Authentication.Social.Abstractions as a Cake Tool
#tool nuget:?package=Rystem.Authentication.Social.Abstractions&version=9.0.2                

What is Rystem?

Rystem.Authentication.Social

This project would be a super project to help the api creator to have fast api behind business interfaces and services dispatched through dependency injection.

How to use it

You need to configure the social information and token settings, for instance the duration of your token.

builder.Services.AddSocialLogin(x =>
{
    x.Google.ClientId = builder.Configuration["SocialLogin:Google:ClientId"];
    x.Google.ClientSecret = builder.Configuration["SocialLogin:Google:ClientSecret"];
    x.Google.RedirectDomain = builder.Configuration["SocialLogin:Google:RedirectDomain"];
    x.Microsoft.ClientId = builder.Configuration["SocialLogin:Microsoft:ClientId"];
    x.Microsoft.ClientSecret = builder.Configuration["SocialLogin:Microsoft:ClientSecret"];
    x.Microsoft.RedirectDomain = builder.Configuration["SocialLogin:Microsoft:RedirectDomain"];
    x.Facebook.ClientId = builder.Configuration["SocialLogin:Facebook:ClientId"];
    x.Facebook.ClientSecret = builder.Configuration["SocialLogin:Facebook:ClientSecret"];
    x.Facebook.RedirectDomain = builder.Configuration["SocialLogin:Facebook:RedirectDomain"];
},
x =>
{
    x.BearerTokenExpiration = TimeSpan.FromHours(1);
    x.RefreshTokenExpiration = TimeSpan.FromDays(10);
});

You need to add in the app builder section the endpoints

app.UseSocialLoginEndpoints();

You can add your provider for user

builder.Services.AddSocialUserProvider<SocialUserProvider>();

SocialUserProvider is a ISocialUserProvider, to call for instance a database or storage to fetch the information about the user with social username/email.

internal sealed class SocialUserProvider : ISocialUserProvider
{
    public Task<SocialUser> GetAsync(string username, IEnumerable<Claim> claims, CancellationToken cancellationToken)
    {
        return Task.FromResult(new SuperSocialUser
        {
            Username = $"a {username}",
            Email = username
        } as SocialUser);
    }

    public async IAsyncEnumerable<Claim> GetClaimsAsync(string? username, CancellationToken cancellationToken)
    {
        await Task.CompletedTask;
        yield return new Claim(ClaimTypes.Name, username!);
        yield return new Claim(ClaimTypes.Upn, "something");
    }
}

public sealed class SuperSocialUser : SocialUser
{
    public string Email { get; set; }
}
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible. 
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
9.0.3 40 12/22/2024
9.0.2 2,750 12/21/2024
9.0.1 1,075 12/21/2024
9.0.0 173,043 11/16/2024
9.0.0-rc.1 96 10/18/2024
6.2.0 219,059 10/9/2024
6.1.1 121 10/9/2024
6.1.0 47,949 9/29/2024
6.0.24 176 9/11/2024
6.0.23 340,216 7/18/2024
6.0.21 340,148 6/18/2024
6.0.20 727,665 6/16/2024
6.0.19 30,384 6/14/2024
6.0.18 138 6/14/2024
6.0.17 138 6/14/2024
6.0.16 49,971 6/10/2024
6.0.15 131 6/9/2024
6.0.14 94,280 5/24/2024
6.0.13 140 5/23/2024
6.0.12 118 5/23/2024
6.0.11 158 5/20/2024
6.0.9 166 5/19/2024
6.0.7 118 5/19/2024