Bee.OAuth2
1.1.2
dotnet add package Bee.OAuth2 --version 1.1.2
NuGet\Install-Package Bee.OAuth2 -Version 1.1.2
<PackageReference Include="Bee.OAuth2" Version="1.1.2" />
<PackageVersion Include="Bee.OAuth2" Version="1.1.2" />
<PackageReference Include="Bee.OAuth2" />
paket add Bee.OAuth2 --version 1.1.2
#r "nuget: Bee.OAuth2, 1.1.2"
#:package Bee.OAuth2@1.1.2
#addin nuget:?package=Bee.OAuth2&version=1.1.2
#tool nuget:?package=Bee.OAuth2&version=1.1.2
Bee.OAuth2
Bee.OAuth2 is a lightweight .NET OAuth2 authentication library that supports multiple providers, including Google, Facebook, LINE, Azure, and Auth0.
Installation
Install via NuGet Package Manager:
dotnet add package Bee.OAuth2
Supported OAuth2 Providers
- LINE
- Azure (Microsoft Entra ID)
- Auth0
Usage Examples
Google OAuth2 Authentication Example
using Bee.OAuth2;
using System;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var options = new GoogleOAuth2Options
{
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
RedirectUri = "http://localhost",
Scopes = { "openid", "email", "profile" }
};
var provider = new GoogleOAuth2Provider(options);
string authUrl = provider.GetAuthorizationUrl("random_state_string");
Console.WriteLine($"Open this URL in your browser: {authUrl}");
Console.Write("Enter authorization code: ");
string code = Console.ReadLine();
var token = await provider.GetAccessTokenAsync(code);
var userInfo = await provider.GetUserInfoAsync(token.AccessToken);
Console.WriteLine($"User Info: {userInfo}");
}
}
Facebook OAuth2 Authentication Example
var options = new FacebookOAuth2Options
{
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
RedirectUri = "http://localhost",
Scopes = { "public_profile", "email" }
};
var provider = new FacebookOAuth2Provider(options);
LINE OAuth2 Authentication Example
var options = new LineOAuth2Options
{
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
RedirectUri = "http://localhost",
Scopes = { "profile", "openid", "email" }
};
var provider = new LineOAuth2Provider(options);
Azure OAuth2 Authentication Example
var options = new AzureOAuth2Options
{
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
RedirectUri = "http://localhost",
Scopes = { "openid", "profile", "email" }
};
var provider = new AzureOAuth2Provider(options);
Auth0 OAuth2 Authentication Example
var options = new Auth0OAuth2Options
{
Domain = "your-domain.auth0.com",
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
RedirectUri = "http://localhost",
Scopes = { "openid", "profile", "email" }
};
var provider = new Auth0OAuth2Provider(options);
License
This project is licensed under the MIT License.
Bee.OAuth2 (中文)
Bee.OAuth2 是一個輕量級的 .NET OAuth2 驗證函式庫,支援 Google、Facebook、LINE、Azure(Microsoft Entra ID)以及 Auth0。
安裝
透過 NuGet 安裝:
dotnet add package Bee.OAuth2
支援的 OAuth2 驗證提供者
- LINE
- Azure(Microsoft Entra ID)
- Auth0
使用範例
Google OAuth2 驗證範例
using Bee.OAuth2;
using System;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var options = new GoogleOAuth2Options
{
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
RedirectUri = "http://localhost",
Scopes = { "openid", "email", "profile" }
};
var provider = new GoogleOAuth2Provider(options);
string authUrl = provider.GetAuthorizationUrl("random_state_string");
Console.WriteLine($"請在瀏覽器中打開此 URL: {authUrl}");
Console.Write("請輸入授權碼: ");
string code = Console.ReadLine();
var token = await provider.GetAccessTokenAsync(code);
var userInfo = await provider.GetUserInfoAsync(token.AccessToken);
Console.WriteLine($"用戶資訊: {userInfo}");
}
}
Facebook OAuth2 驗證範例
var options = new FacebookOAuth2Options
{
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
RedirectUri = "http://localhost",
Scopes = { "public_profile", "email" }
};
var provider = new FacebookOAuth2Provider(options);
LINE OAuth2 驗證範例
var options = new LineOAuth2Options
{
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
RedirectUri = "http://localhost",
Scopes = { "profile", "openid", "email" }
};
var provider = new LineOAuth2Provider(options);
Azure OAuth2 驗證範例
var options = new AzureOAuth2Options
{
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
RedirectUri = "http://localhost",
Scopes = { "openid", "profile", "email" }
};
var provider = new AzureOAuth2Provider(options);
Auth0 OAuth2 驗證範例
var options = new Auth0OAuth2Options
{
Domain = "your-domain.auth0.com",
ClientId = "your-client-id",
ClientSecret = "your-client-secret",
RedirectUri = "http://localhost",
Scopes = { "openid", "profile", "email" }
};
var provider = new Auth0OAuth2Provider(options);
授權
本專案採用 MIT License。
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Bee.Base (>= 3.1.6)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Bee.OAuth2:
Package | Downloads |
---|---|
Bee.OAuth2.WinForms
Bee.OAuth2.WinForms is a Windows Forms library that provides a user interface for OAuth2 authentication. It supports Google, Facebook, LINE, Azure, and Auth0 authentication with an easy-to-use UI component. |
|
Bee.OAuth2.AspNet
Bee.OAuth2.AspNet is an OAuth2 authentication library designed for ASP.NET WebForms / MVC, supporting Google, Facebook, LINE, Azure, and Auth0. |
|
Bee.OAuth2.Desktop
Bee.OAuth2.Desktop is a Windows Forms library that provides a user interface for OAuth2 authentication. It supports Google, Facebook, LINE, Azure, and Auth0 authentication with an easy-to-use UI component. |
|
Bee.OAuth2.AspNetCore
Bee.OAuth2.AspNetCore is an OAuth2 authentication library designed for ASP.NET Core, supporting Google, Facebook, LINE, Azure, and Auth0. |
GitHub repositories
This package is not used by any popular GitHub repositories.