Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

okta-sdk-dotnet

> 编程语言
Open source

A .NET SDK for interacting with the Okta management API, enabling server-side code to manage Okta users, groups, applications, and more.

181 stars0 likes1 views
WebsiteGitHub

About

A .NET SDK for interacting with the Okta management API, enabling server-side code to manage Okta users, groups, applications, and more.

[][devforum] [][dotnetdocs]

Okta .NET management SDK

  • Release status
  • Need help?
  • Getting started
  • Usage guide
  • Configuration reference
  • Building the SDK
  • Contributing

This repository contains the Okta management SDK for .NET. This SDK can be used in your server-side code to interact with the Okta management API and:

  • Create and update users with the Users API
  • Add security factors to users with the Factors API
  • Manage groups with the Groups API
  • Manage applications with the Apps API
  • Manage logs with the Logs API
  • Manage sessions with the Sessions API
  • Manage templates with the Custom Templates API
  • Manage identity providers with the Identity Providers API
  • Manage authorization servers with the Authorization Servers API
  • Manage event hooks with the Event Hooks Management API
  • Manage inline hooks with the Inline Hooks Management API.
  • Manage features with the Features API.
  • Manage linked objects with the Linked Objects API.
  • Manage trusted origins with the Trusted Origins API.
  • Manage user types with the User Types API.
  • Manage custom domains with the Domains API.
  • Manage network zones with the Zones API's endpoints.
  • Much more!

Note: For more details about the APIs and models the SDK support, check out the API docs

We also publish these other libraries for .NET:

  • Okta ASP.NET middleware
  • Okta .NET Authentication SDK

You can learn more on the [Okta + .NET][lang-landing] page in our documentation.

Release status

This library uses semantic versioning and follows Okta's library version policy.

:heavy_check_mark: The current stable major version series is: 10.x

Version Status
10.x :heavy_check_mark: Stable (migration guide
9.x :warning: Retiring on April 3rd 2026
8.x :x: Retired

The latest release can always be found on the [releases page][github-releases]. For more information about our SDKs' lifecycle, check out our docs.

Need help?

If you run into problems using the SDK, you can

  • Ask questions on the [Okta Developer Forums][devforum]
  • Post [issues][github-issues] here on GitHub (for code errors)

Getting Started

The SDK is compatible with:

  • .NET Standard 2.1
  • .NET Framework 4.6.1 or higher
  • .NET Core 3.0 or higher
  • .NET 5.0 or higher

Visual Studio 2017 or newer is required as previous versions are not compatible with the above frameworks.

Install using Nuget Package Manager

  1. Right-click on your project in the Solution Explorer and choose Manage Nuget Packages...
  2. Search for Okta. Install the Okta.Sdk package.

Install using The Package Manager Console

Simply run install-package Okta.Sdk. Done!

You'll also need:

  • An Okta account, called an organization (sign up for a free developer organization if you need one)
  • An API token

Initialize an API client

Using API class constructor

Construct a client instance by creating a Configuration object, setting your Okta domain name and API token and passing the Configuration object to the API client class constructor:

…

Hard-coding the Okta domain and API token works for quick tests, but for real projects you should use a more secure way of storing these values (such as environment variables). This library supports a few different configuration sources, covered in the configuration reference section.

To use the API client with an HTTP proxy, you can either setup your proxy via different configuration sources, covered in the configuration reference section, or via API constructor. If you have both, the proxy passed via constructor will take precedence.

csharp
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

var appsApi = new ApplicationApi(webProxy : webProxy);

Using OktaApiClientOptions & OktaApiServiceBuilder

Beginning with Okta.Sdk version 9.2.0 you can use the OktaApiClientOptions class to instantiate API clients using a fluent builder syntax. The static methods defined on OktaApiClientOptions return an instance of OktaApiServiceBuilder which provides a mechanism to specify more complex configuration options.

…

Using OktaApiClientOptions and the resulting OktaApiServiceBuilder you can instantiate multiple API clients that have the same configuration:

…

Interceptors

Beginning with Okta.Sdk version 9.2.0, using OktaApiServiceBuilder by way of OktaApiClientOptions, you can specify custom Interceptors to be used during API client operations. Further, if your custom implementation has constructor dependencies, those dependencies should be specified using the For and Use methods defined on OktaApiServiceBuilder.

…

See also:

  • Implementing an interceptor

Custom HttpMessageHandler

Beginning with Okta.Sdk version 9.2.0, using OktaApiServiceBuilder by way of OktaApiClientOptions, you can specify custom HttpMessageHandler to be used during API client operations. Further, if your custom implementation has constructor dependencies, those dependencies should be specified using the For and Use methods defined on OktaApiServiceBuilder.

…

OAuth 2.0

Okta allows you to interact with Okta APIs using scoped OAuth 2.0 access tokens. Each access token enables the bearer to perform specific actions on specific Okta endpoints, with that ability controlled by which scopes the access token contains.

This SDK supports this feature only for service-to-service applications. Check out our guides to learn more about how to register a new service application using a private and public key pair.

When using this approach you won't need an API Token because the SDK will request an access token for you. In order to use OAuth 2.0, construct an API client instance by passing the following parameters:

csharp
var oauthAppsApi = new ApplicationApi(new Configuration
{
    OktaDomain = "https://{{yourOktaDomain}}",
    AuthorizationMode = AuthorizationMode.PrivateKey,
    ClientId = "{{clientId}}",
    Scopes = new List { "okta.users.read", "okta.apps.read" }, // Add all the scopes you need
    PrivateKey =  new JsonWebKeyConfiguration(jsonString)
});

Key object for assigning to the PrivateKey can be created and initialized inline like in this example for RSA key:

csharp
var privateKey = new JsonWebKeyConfiguration
{
    P = "{{P}}",
    Kty = "RSA",
    Q = "{{Q}}",
    D = "{{D}}",
    E = "{{E}}",
    Kid = "{{P}}",
    Qi = "{{Qi}}"
};

var configuration = new Configuration
{
    OktaDomain = "https://{{yourOktaDomain}}",
    AuthorizationMode = AuthorizationMode.PrivateKey,
    ClientId = "{{clientId}}",
    Scopes = new HashSet { "okta.users.read", "okta.apps.read" }, // Add all the scopes you need
    PrivateKey = privateKey
};

var oauthAppsApi = new ApplicationApi(configuration);

Keeping the private key out of the process

Both examples above hand the SDK the key material itself, which means it has to exist somewhere readable - in okta.yaml, in appsettings.json, or in a string in memory. If the key lives somewhere that signs on your behalf without surrendering it, such as a TPM, a hardware security module, or a non-exportable certificate, set PrivateKeySigningCredentials instead of PrivateKey and the SDK signs the client assertion through it:

csharp
var cngKey = CngKey.Open("my-okta-key", new CngProvider("Microsoft Platform Crypto Provider"));

var configuration = new Configuration
{
    OktaDomain = "https://{{yourOktaDomain}}",
    AuthorizationMode = AuthorizationMode.PrivateKey,
    ClientId = "{{clientId}}",
    Scopes = new HashSet { "okta.users.read" },
    PrivateKeySigningCredentials =
        new SigningCredentials(new RsaSecurityKey(new RSACng(cngKey)), SecurityAlgorithms.RsaSha256),
};

Any SigningCredentials works, so the same applies to an X509Certificate2 whose key cannot be exported or to a key held in a cloud key store. PrivateKeySigningCredentials takes precedence over PrivateKey when both are set, and it is deliberately never read from or written to a configuration file.

It is possible to use an access token you retrieved outside of the SDK for authentication. For that, set Configuration.AuthorizationMode configuration property to AuthorizationMode.BearerToken and Configuration.AccessToken to the token string.

Note: Starting from 8.x series the Okta management SDK added support for DPoP. If the SDK detects the application has DPoP enabled, it will silently proceed to obtain a DPoP-bound access token, and will generate a new DPoP Proof JWT for every request. There's no additional configuration required for developers.

Usage guide

These examples will help you understand how to use this library. You can also browse the full [API reference documentation][dotnetdocs].

Once you initialize an API client, you can call methods to make requests to the Okta API.

Get a User

csharp
// Get the user with a user ID or login
var user = await userApi.GetUserAsync("");

The string argument for GetUserAsync can be the user's ID or the user's login (usually their email).

List all Users

The SDK will automatically paginate Okta collections for you:

csharp
// These different styles all perform the same action:
var allUsers = await userApi.ListUsers().ToListAsync();
var allUsers = await userApi.ListUsers().ToArrayAsync();

Filter or search for Users

csharp
var foundUsers = await userApi
                        .ListUsers(search: $"profile.nickName eq \"Skywalker\"")
                        .ToArrayAsync();

Create a User

…

Activate a User

csharp
// Activate the user
var userLifecycleApi = new UserLifecycleApi();
await userLifecycleApi.ActivateUserAsync(createdUser.Id, false);

Update a User

csharp
// Update profile
createdUser.Profile.NickName = nickName;
var updateUserRequest = new UpdateUserRequest
{
    Profile = createdUser.Profile
};

var updatedUser = await _userApi.UpdateUserAsync(createdUser.Id, updateUserRequ

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C#

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言