Skip to content

Provides a generic OAuth2 handler to be used within System.Net.Http.HttpClient instances, enabling OAuth2 authorization for any requests made through the aforementioned HTTP client.

License

Notifications You must be signed in to change notification settings

fastchannel/httpclient-oauth2handler

Repository files navigation

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");
    // ...
}

About

Provides a generic OAuth2 handler to be used within System.Net.Http.HttpClient instances, enabling OAuth2 authorization for any requests made through the aforementioned HTTP client.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages