Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huysentruitw/oauth2-client-handler
Managed .NET (C#) library for use with HttpClient to transparantly call authorized WebAPI
https://github.com/huysentruitw/oauth2-client-handler
api authentication dotnet httpclient oauth2 oauth2-client openid-connect
Last synced: 2 days ago
JSON representation
Managed .NET (C#) library for use with HttpClient to transparantly call authorized WebAPI
- Host: GitHub
- URL: https://github.com/huysentruitw/oauth2-client-handler
- Owner: huysentruitw
- License: mit
- Created: 2016-02-15T20:47:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-24T15:40:19.000Z (3 months ago)
- Last Synced: 2024-10-06T14:34:32.509Z (about 1 month ago)
- Topics: api, authentication, dotnet, httpclient, oauth2, oauth2-client, openid-connect
- Language: C#
- Homepage:
- Size: 50.8 KB
- Stars: 34
- Watchers: 3
- Forks: 25
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OAuth2 Client Handler
[![Build status](https://ci.appveyor.com/api/projects/status/9fepyg7kuhgmulh1/branch/master?svg=true)](https://ci.appveyor.com/project/huysentruitw/oauth2-client-handler/branch/master)
Managed .NET library for use with HttpClient to transparantly call authorized remote API protected with OAuth2 or OpenID Connect.
Supports .NET Framework 4.5+ and .NET Standard / .NET Core.
## Get it on NuGet
PM> Install-Package OAuth2ClientHandler
## Usage
```C#
var options = new OAuthHttpHandlerOptions
{
AuthorizerOptions = new AuthorizerOptions
{
AuthorizeEndpointUrl = new Uri("http://localhost/authorizer"),
TokenEndpointUrl = new Uri("http://localhost/token"),
ClientId = "MyId",
ClientSecret = "MySecret",
GrantType = GrantType.ClientCredentials
}
};using (var client = new HttpClient(new OAuthHttpHandler(options)))
{
client.BaseAddress = new Uri("http://localhost");
var response = await client.GetAsync("/api/protected_api_call");
// ...
}
```