Okta.AuthFoundation 0.2.0

dotnet add package Okta.AuthFoundation --version 0.2.0
                    
NuGet\Install-Package Okta.AuthFoundation -Version 0.2.0
                    
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="Okta.AuthFoundation" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Okta.AuthFoundation" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Okta.AuthFoundation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Okta.AuthFoundation --version 0.2.0
                    
#r "nuget: Okta.AuthFoundation, 0.2.0"
                    
#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.
#:package Okta.AuthFoundation@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Okta.AuthFoundation&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Okta.AuthFoundation&version=0.2.0
                    
Install as a Cake Tool

Okta Client SDK for .NET

A .NET SDK for integrating Okta authentication and OAuth2 flows into your applications. The SDK provides token management, credential storage, JWT validation, and support for multiple OAuth2 authentication flows.

Status: This SDK is currently in early development (v0.1.0, MVP) and currently focuses on the Authorization Code grant with PKCE.

Packages

Package Description
Okta.AuthFoundation Core library providing OAuth2 client, token management, credential storage, JWT validation, and HTTP abstractions.
Okta.OAuth2 OAuth2 authentication flows including Authorization Code (with PKCE), Resource Owner Password, and Session Logout.

Prerequisites

Installation

dotnet add package Okta.AuthFoundation
dotnet add package Okta.OAuth2

Quick Start

Authorization Code Flow (with PKCE)

using Okta.AuthFoundation.OAuth2;
using Okta.OAuth2.Flows;

var config = new OAuth2ClientConfiguration(
    new Uri("https://your-domain.okta.com/oauth2/default"),
    "your-client-id",
    new List<string> { "openid", "profile", "email", "offline_access" }
);

var client = new OAuth2Client(config);
var flow = new AuthorizationCodeFlow(client, "http://localhost:8080/callback");

// 1. Generate the authorization URL and redirect the user
Uri authorizeUrl = await flow.StartAsync();

// 2. After the user authenticates, exchange the callback for tokens
var response = await flow.ResumeAsync(callbackUri);

if (response.IsSuccess)
{
    Token token = response.Result;
    Console.WriteLine($"Access Token: {token.AccessToken}");
}

Samples

The repository includes sample applications demonstrating SDK usage:

Sample Description Platform
ConsoleWebRedirectSample Console app using the Authorization Code flow with a loopback HTTP listener Cross-platform
WebRedirectSample WPF desktop app using the Authorization Code flow Windows only
ResourceOwnerFlowSample Console app using the Resource Owner Password flow Cross-platform

Running the Console Sample

  1. Copy the example configuration and fill in your Okta settings:
{
  "OAuth2": {
    "IssuerUrl": "https://your-domain.okta.com/oauth2/default",
    "ClientId": "your-client-id",
    "RedirectUri": "http://localhost:8080/callback",
    "Scopes": [ "openid", "profile", "email", "offline_access" ]
  }
}
  1. Run the sample:
cd Samples/ConsoleWebRedirectSample
# Edit appsettings.json with your Okta configuration
dotnet run

Time Coordination

Device clocks cannot be relied on. Users adjust them manually for a variety of reasons (including changing the date to claim daily rewards in games), devices drift, and portable devices roam across time zones. A clock that is wildly off affects every time-sensitive operation in the SDK: token expiration checks, iat/auth_time/max_age validation, token acquisition timestamps, proactive refresh decisions, rate limit header parsing, retry delay calculation, and device code expiry tracking.

The SDK routes every time query through ITimeCoordinator. The default implementation observes the Date header returned by the authorization server on each response and offsets the system clock accordingly, converging on the server's view of time after the first request.

Consumers who need a different source (e.g. a network time service, a hardware-backed clock, or a fixed clock in tests) can register their own at app startup:

using Okta.AuthFoundation;

OktaServices.AddSingleton<ITimeCoordinator>(new MyCustomTimeCoordinator());

Multiple authorization servers: DefaultTimeCoordinator is a process-wide singleton, so all OAuth2Client instances share the same offset. Each response's Date header replaces the previous offset entirely — there is no per-server isolation. When communicating with multiple authorization servers whose clocks differ, the effective adjustment at any point is whatever the last-responding server reported, not the one whose tokens are currently being validated. This is a known characteristic of the design. A custom ITimeCoordinator can be registered via OktaServices.AddSingleton<ITimeCoordinator>(...).

Building

Windows

dotnet build Okta.Client.Sdk.sln

Linux / macOS / WSL

Use the cross-platform solution filter, which excludes the Windows-only WPF sample:

dotnet build Okta.Client.Sdk.CrossPlatform.slnf

Running Tests

dotnet test Okta.Client.Sdk.CrossPlatform.slnf

License

Copyright 2026 Okta, Inc. Licensed under the Apache License, Version 2.0. See NOTICE for third-party attributions.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Okta.AuthFoundation:

Package Downloads
Okta.OAuth2

OAuth2 and OIDC authentication flows for the Okta .NET SDK: Authorization Code with PKCE, Device Authorization, Resource Owner, Session Logout, and Token Exchange.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 118 11/18/2026