Authenticator.OAuth
1.0.5
dotnet add package Authenticator.OAuth --version 1.0.5
NuGet\Install-Package Authenticator.OAuth -Version 1.0.5
<PackageReference Include="Authenticator.OAuth" Version="1.0.5" />
<PackageVersion Include="Authenticator.OAuth" Version="1.0.5" />
<PackageReference Include="Authenticator.OAuth" />
paket add Authenticator.OAuth --version 1.0.5
#r "nuget: Authenticator.OAuth, 1.0.5"
#:package Authenticator.OAuth@1.0.5
#addin nuget:?package=Authenticator.OAuth&version=1.0.5
#tool nuget:?package=Authenticator.OAuth&version=1.0.5
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).
Clone this repository to your local machine:
git clone https://github.com/abdulmoiz99/Authenticator.git
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:
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.
Configure in Your App:
In the S
Startup.cs
orProgram.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:
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
).
Configure in Your App:
In the
Startup.cs
orProgram.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 | Versions 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. |
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.