Authress.SDK
1.2.25
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.25
NuGet\Install-Package Authress.SDK -Version 1.2.25
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.25" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Authress.SDK --version 1.2.25
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Authress.SDK, 1.2.25"
#r directive can be used in F# Interactive and Polyglot Notebooks. 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.25
// Install Authress.SDK as a Cake Tool
#tool nuget:?package=Authress.SDK&version=1.2.25
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;
});
// Get an authress custom domain: https://authress.io/app/#/settings?focus=domain
var authressSettings = new HttpClientSettings { ApiBasePath = "https://CUSTOM_DOMAIN.application.com", };
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);
// Get an authress custom domain: https://authress.io/app/#/settings?focus=domain
var authressSettings = new HttpClientSettings { ApiBasePath = "https://CUSTOM_DOMAIN.application.com", };
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 Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Microsoft.IdentityModel.Tokens (>= 6.30.1)
- Newtonsoft.Json (>= 13.0.3)
- Portable.BouncyCastle (>= 1.9.0)
- ScottBrady.IdentityModel (>= 1.3.1)
- System.IdentityModel.Tokens.Jwt (>= 6.30.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.5.72 | 106 | 3/5/2024 |
1.5.71 | 89 | 2/25/2024 |
1.5.69 | 88 | 2/14/2024 |
1.5.65 | 169 | 1/23/2024 |
1.5.63 | 74 | 1/22/2024 |
1.5.60 | 74 | 1/22/2024 |
1.5.59 | 78 | 1/22/2024 |
1.5.57 | 192 | 1/10/2024 |
1.5.55 | 79 | 1/9/2024 |
1.4.53 | 80 | 1/9/2024 |
1.4.52 | 77 | 1/9/2024 |
1.4.50 | 83 | 1/9/2024 |
1.4.48 | 86 | 1/9/2024 |
1.4.45 | 135 | 8/24/2023 |
1.4.44 | 118 | 8/19/2023 |
1.4.41 | 154 | 8/9/2023 |
1.4.40 | 142 | 8/6/2023 |
1.4.39 | 128 | 8/6/2023 |
1.4.37 | 148 | 8/5/2023 |
1.4.35 | 154 | 8/5/2023 |
1.4.33 | 137 | 8/5/2023 |
1.4.31 | 138 | 8/4/2023 |
1.4.30 | 134 | 8/4/2023 |
1.3.29 | 162 | 5/17/2023 |
1.3.26 | 128 | 5/15/2023 |
1.2.25 | 127 | 5/14/2023 |
1.2.22 | 816 | 11/4/2022 |
1.2.20 | 390 | 6/23/2022 |
1.2.18 | 440 | 2/10/2022 |
1.2.15 | 419 | 2/10/2022 |
1.2.13 | 419 | 2/9/2022 |
1.2.11 | 417 | 2/9/2022 |
1.2.8 | 419 | 2/9/2022 |
1.1.53 | 1,348 | 4/12/2021 |
1.1.50 | 338 | 2/19/2021 |
1.1.46 | 1,884 | 12/5/2020 |
1.0.43 | 2,681 | 6/27/2020 |