Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 1.09 KB

File metadata and controls

36 lines (27 loc) · 1.09 KB

OAuth2 HttpClient Handler, by Fastchannel

Build status

Install from nuget

Managed .NET library to be used within HttpClient instances, enabling them to transparantly call authorized remote APIs protected with OAuth2 or OpenID-Connect standards.

Supports .NET Framework 4.5+ and .NET Standard / .NET Core.

Get it on NuGet

PM> Install-Package Fastchannel.HttpClient.OAuth2Handler

Basic Usage

var options = new OAuthHttpHandlerOptions
{
    AuthorizerOptions = new AuthorizerOptions
    {
        TokenEndpointUrl = new Uri("https://localhost/token"),
        GrantType = GrantType.ClientCredentials,
        ClientId = "SomeClientId",
        ClientSecret = "SomeClientSecret"
    }
};

using (var client = new HttpClient(new OAuthHttpHandler(options)))
{
    client.BaseAddress = new Uri("http://localhost");
    var response = await client.GetAsync("/api/protected_api_call");
    // ...
}