Authress.SDK 1.2.20

There is a newer version of this package available.
See the version list below for details.
dotnet add package Authress.SDK --version 1.2.20
NuGet\Install-Package Authress.SDK -Version 1.2.20
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.20" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Authress.SDK --version 1.2.20
#r "nuget: Authress.SDK, 1.2.20"
#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.20

// Install Authress.SDK as a Cake Tool
#tool nuget:?package=Authress.SDK&version=1.2.20

authress-sdk.cs

The Authress SDK for C#

NuGet version

Usage

Package Management
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 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.

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 94 3/5/2024
1.5.71 87 2/25/2024
1.5.69 85 2/14/2024
1.5.65 151 1/23/2024
1.5.63 71 1/22/2024
1.5.60 68 1/22/2024
1.5.59 73 1/22/2024
1.5.57 163 1/10/2024
1.5.55 75 1/9/2024
1.4.53 77 1/9/2024
1.4.52 72 1/9/2024
1.4.50 79 1/9/2024
1.4.48 81 1/9/2024
1.4.45 133 8/24/2023
1.4.44 116 8/19/2023
1.4.41 151 8/9/2023
1.4.40 140 8/6/2023
1.4.39 126 8/6/2023
1.4.37 146 8/5/2023
1.4.35 151 8/5/2023
1.4.33 135 8/5/2023
1.4.31 136 8/4/2023
1.4.30 132 8/4/2023
1.3.29 159 5/17/2023
1.3.26 126 5/15/2023
1.2.25 125 5/14/2023
1.2.22 815 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 417 2/9/2022
1.1.53 1,289 4/12/2021
1.1.50 337 2/19/2021
1.1.46 1,823 12/5/2020
1.0.43 2,659 6/27/2020