Authress.SDK
1.2.15
.NET Standard 2.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Authress.SDK --version 1.2.15
NuGet\Install-Package Authress.SDK -Version 1.2.15
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Authress.SDK" Version="1.2.15" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Authress.SDK --version 1.2.15
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Authress.SDK, 1.2.15"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Authress.SDK as a Cake Addin
#addin nuget:?package=Authress.SDK&version=1.2.15
// Install Authress.SDK as a Cake Tool
#tool nuget:?package=Authress.SDK&version=1.2.15
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
authress-sdk.cs
The Authress SDK for C#
Usage
Package Management
run:
dotnet add Authress.SDK
(or install via visual tools)
Authorize users using user identity token
using Authress.SDK;
namespace Microservice
{
public class Controller
{
public static async void Route()
{
// automatically populate forward the users token
// 1. instantiate all the necessary classes (example using ASP.NET or MVC, but any function works)
// If using the HttpContextAccessor, register it first inside the application root
// services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
var tokenProvider = new DynamicTokenProvider(() =>
{
// Then get the access token from the incoming API request and return it
var httpContextAccessor = ServiceProvider.GetRequiredService<IHttpContextAccessor>();
var accessToken = await httpContextAccessor.HttpContext.GetTokenAsync("Bearer", "access_token");
return accessToken;
});
var authressSettings = new HttpClientSettings { ApiBasePath = "https://DOMAIN.api.authress.io", };
var authressClient = new AuthressClient(tokenProvider, authressSettings);
// 2. At runtime attempt to Authorize the user for the resource
await authressClient.AuthorizeUser("USERID", "RESOURCE_URI", "PERMISSION");
// API Route code
// ...
}
}
}
Authorize using an explicitly set token each time
using Authress.SDK;
namespace Microservice
{
public class Controller
{
public static async void Route()
{
// automatically populate forward the users token
// 1. instantiate all the necessary classes
var tokenProvider = new ManualTokenProvider();
var authressSettings = new HttpClientSettings { ApiBasePath = "https://DOMAIN.api.authress.io", };
var authressClient = new AuthressClient(tokenProvider, authressSettings);
// 2. At runtime attempt to Authorize the user for the resource
tokenProvider.setToken(userJwt);
await authressClient.AuthorizeUser("USERID", "RESOURCE_URI", "PERMISSION");
// API Route code
// ...
}
}
}
Authorize users using client secret
using Authress.SDK;
namespace Microservice
{
public class Controller
{
public static async void Route()
{
// accessKey is returned from service client creation in Authress UI
// 1. instantiate all the necessary classes
var accessKey = 'ACCESS_KEY';
// Assuming it was encrypted in storage, decrypt it
var decodedAccessKey = decrypt(accessKey);
var tokenProvider = new AuthressClientTokenProvider(decodedAccessKey);
var authressSettings = new HttpClientSettings { ApiBasePath = "https://DOMAIN.api.authress.io", };
var authressClient = new AuthressClient(tokenProvider, authressSettings);
// Attempt to Authorize the user for the resource
// 2. At runtime the token provider will automatically pull the token forward
await authressClient.AuthorizeUser("USERID", "RESOURCE_URI", "PERMISSION");
// API Route code
// ...
}
}
}
Development guidelines for the Authress SDK
This package is autogenerated via the openapi generator, which can be found at:
curl -XPOST https://generator3.swagger.io/api/generate -H 'content-type: application/json' -d '{"specURL" : "https://api.authress.io/.well-known/openapi.json","lang" : "csharp-dotnet2","type" : "CLIENT","codegenVersion" : "V3"}' --output sdk_files
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
.NET Core | netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard2.1 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Microsoft.IdentityModel.Tokens (>= 6.15.1)
- Newtonsoft.Json (>= 12.0.3)
- Portable.BouncyCastle (>= 1.9.0)
- ScottBrady.IdentityModel (>= 1.3.1)
- System.IdentityModel.Tokens.Jwt (>= 6.15.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.