Skip to content

scalepoint-tech/oauth-token-net-client

Repository files navigation

OAuth Token Endpoint Client for .NET

Description

Client helper for OAuth2 Token endpoint. Supports "Client Credentials" flow with "client_secret", RS256 JWT "client_assertion", custom grants and token caching.

Features

If you need support for other grant types or authentication methods, please check IdentityModel2.

Getting started

Install from NuGet:

Install-Package Scalepoint.OAuth.TokenClient

Obtaining access token from Authorization Server token endpoint is as simple as this:

private_key_jwt
var tokenClient = new ClientCredentialsGrantTokenClient(
                        tokenEndpointUrl,
                        new JwtBearerClientAssertionCredentials(
                            tokenEndpointUrl,
                            clientId,
                            x509certificate
                        )
                  );

var accessToken = await tokenClient.GetTokenAsync(new [] { scope1, scope2 });
client_secret
var tokenClient = new ClientCredentialsGrantTokenClient(
                        tokenEndpointUrl,
                        new ClientSecretCredentials(
                            clientId,
                            clientSecret
                        )
                  );

var accessToken = await tokenClient.GetTokenAsync(new [] { scope1, scope2 });

Also check our examples repository example: