Authenticator.OAuth 1.0.5

dotnet add package Authenticator.OAuth --version 1.0.5
                    
NuGet\Install-Package Authenticator.OAuth -Version 1.0.5
                    
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="Authenticator.OAuth" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Authenticator.OAuth" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Authenticator.OAuth" />
                    
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 Authenticator.OAuth --version 1.0.5
                    
#r "nuget: Authenticator.OAuth, 1.0.5"
                    
#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 Authenticator.OAuth@1.0.5
                    
#: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=Authenticator.OAuth&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Authenticator.OAuth&version=1.0.5
                    
Install as a Cake Tool

Authenticator OAuth Library

Authenticator OAuth Library is a .NET class library that simplifies the integration of OAuth-based authentication for multiple providers. Currently, it supports Google and GitHub OAuth authentication, with plans to extend support to other OAuth providers like Facebook, Twitter, etc. This library is designed to be a one-stop solution for adding authentication to your .NET applications.

Features

  • Google Authentication: Easily integrates Google OAuth 2.0 login.
  • GitHub Authentication: Seamless integration with GitHub's OAuth 2.0.
  • Scalable: Designed to add more OAuth providers with minimal effort.
  • Customizable: Flexible configurations to customize authentication flows and error handling.
  • Security: Uses OAuth 2.0 protocols to ensure secure authentication.

Installation

You can add the library to your project by including it as a reference or by using NuGet (when available).

  1. Clone this repository to your local machine:

    git clone https://github.com/abdulmoiz99/Authenticator.git
    
  2. Add the Class Library to your .NET project:

    • Open your project in Visual Studio.
    • Right-click on Solution Explorer and choose Add > Existing Project.
    • Navigate to the folder where the library is located and select the .csproj file.

Configuration

Authentication Settings

To configure authentication, add the following settings to your appsettings.json file:

        {
        "AuthenticationSettings": {
            "Google": {
                "ClientId": "your-google-client-id",
                "ClientSecret": "your-google-client-secret"
                },
            "GitHub": {
                "ClientId": "your-github-client-id",
                "ClientSecret": "your-github-client-secret"
                }
            }
        }

Google Authentication Setup

To enable Google OAuth, follow these steps:

  1. Create Google OAuth Credentials:

    • Go to the Google Developer Console.
    • Create a new project.
    • Enable the Google+ API and create OAuth credentials.
    • Add your client ID and client secret to your .NET application configuration.
  2. Configure in Your App:

    In the SStartup.cs or Program.cs, register the Google authentication without the need for clientId and clientSecret parameters:

    builder.Services.Configure<AuthenticationSettings>(builder.Configuration.GetSection("AuthenticationSettings"));
    builder.Services.AddGoogleAndGithubAuthentication();
    

GitHub Authentication Setup

To enable GitHub OAuth:

  1. Create GitHub OAuth Credentials:

    • Go to GitHub Developer Settings.
    • Register a new OAuth application and get your Client ID and Client Secret.
    • Set the callback URL to match your application configuration (e.g., https://localhost:7148/api/authentication/github-response).
  2. Configure in Your App:

    In the Startup.cs or Program.cs, register GitHub authentication as shown below:

    builder.Services.Configure<AuthenticationSettings>(builder.Configuration.GetSection("AuthenticationSettings"));
    builder.Services.AddGoogleAndGithubAuthentication();
    

Usage

Google Login Example

To initiate Google login, call the GoogleLogin method in your authentication service:

public IActionResult LoginWithGoogle()
{
    return _authenticationService.GoogleLogin("/api/authentication/google-response");
}
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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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

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
1.0.5 135 10/7/2024
1.0.4 114 10/7/2024
1.0.3 121 10/6/2024
1.0.2 118 10/6/2024
1.0.1 118 10/5/2024