This library uses semantic versioning and follows Okta's library version policy. In short, we don't make breaking changes unless the major version changes!
In previous versions, null resource properties would result in a resource object with all its properties set to null. Now, null resource properties will result in null property value.
Before:
{ deserializedResource.Prop1.Should().Be("Hello World!");
prop1 : "Hello World!", => deserializedResource.NestedObject.Should().NotBeNull();
nestedObject: null deserializedResource.NestedObject.Prop1.Should().BeNull();
}
Now:
{ deserializedResource.Prop1.Should().Be("Hello World!");
prop1 : "Hello World!", => deserializedResource.NestedObject.Should().BeNull();
nestedObject: null
}
Since this is a breaking change in the default behavior, the major version of Okta.Sdk was incremented to 5; the latest version is now 5.0.0.
If you were relying on this behavior, make sure to update your code and verify the resource is not null before accessing its properties.
The 3.x series of this library introduced a new client for Authorization Servers. This client had an issue when trying to retrieve policy rules for given Authorization Server Policy. In order to fix this issue, new policy models were created to represent both policies and policy rules for Authorization Servers.
Because this was a breaking change, Okta.Sdk was published with version numbers starting from 4.0.0.
All Authorization Server methods that manipulate Policies and/or Policy Rules have changed:
Below APIs has undergone a signature change.
public ICollectionClient<IPolicy> ListPolicies()changed topublic ICollectionClient<IAuthorizationServerPolicy> ListPolicies()
Note that the method returns now an
IAuthorizationServerPolicy.
public Task<IPolicy> CreatePolicyAsync(IPolicy policy, CancellationToken cancellationToken = default(CancellationToken))changed topublic Task<IAuthorizationServerPolicy> CreatePolicyAsync(IAuthorizationServerPolicy policy, CancellationToken cancellationToken = default(CancellationToken))
Note that the method expects and returns now an
IAuthorizationServerPolicy.
public Task<IPolicy> GetPolicyAsync(string policyId, CancellationToken cancellationToken = default(CancellationToken))changed topublic Task<IAuthorizationServerPolicy> GetPolicyAsync(string policyId, CancellationToken cancellationToken = default(CancellationToken))
Note that the method returns now an
IAuthorizationServerPolicy.
Below APIs has undergone a signature change.
public ICollectionClient<IPolicy> ListAuthorizationServerPolicies(string authServerId)changed topublic ICollectionClient<IAuthorizationServerPolicy> ListAuthorizationServerPolicies(string authServerId)
Note that the method returns now an
ICollectionClientofIAuthorizationServerPolicy.
public async Task<IPolicy> CreateAuthorizationServerPolicyAsync(IPolicy policy, string authServerId, CancellationToken cancellationToken = default(CancellationToken))change topublic async Task<IAuthorizationServerPolicy> CreateAuthorizationServerPolicyAsync(IAuthorizationServerPolicy policy, string authServerId, CancellationToken cancellationToken = default(CancellationToken))
Note that the method expects and returns now an
IAuthorizationServerPolicy.
public async Task<IPolicy> GetAuthorizationServerPolicyAsync(string authServerId, string policyId, CancellationToken cancellationToken = default(CancellationToken))changed topublic async Task<IAuthorizationServerPolicy> GetAuthorizationServerPolicyAsync(string authServerId, string policyId, CancellationToken cancellationToken = default(CancellationToken))
Note that the method returns now an
IAuthorizationServerPolicy.
public async Task<IPolicy> UpdateAuthorizationServerPolicyAsync(IPolicy policy, string authServerId, string policyId, CancellationToken cancellationToken = default(CancellationToken))changed topublic async Task<IAuthorizationServerPolicy> UpdateAuthorizationServerPolicyAsync(IAuthorizationServerPolicy policy, string authServerId, string policyId, CancellationToken cancellationToken = default(CancellationToken))
Note that the method expects and returns now an
IAuthorizationServerPolicy.
You now can get policy rules given an Authorization Server Policy:
var authorizationServerPolicy = await authorizationServer.GetPolicyAsync(policy.Id);
var authorizationServerPolicyRules = await authorizationServerPolicy.ListPolicyRules(authorizationServer.Id).ToListAsync();Version 3.0.0 of this library introduces a number of breaking changes from previous versions; in addition to new classes some class definitions are no longer backward compatible due to method renames and signature changes, see Breaking Changes.
The following is a list of changes that break backward compatibility in version 3.0.0.
Okta.Sdk.OktaClient
CreatedScoped(Okta.Sdk.RequestContext requestContext)
— RenamedCreateScoped(Okta.Sdk.RequestContext requestContext)
Okta.Sdk.GroupsClient
ListGroups(string q, string filter, string after, int limit, string expand)
— Signature changedListGroups(string q, string filter, string after, int limit)ListRules(int limit, string after, string expand)
— Renamed with new signatureListGroupRules(int limit, string after, string search, string expand)CreateRuleAsync(Okta.Sdk.IGroupRule groupRule, CancellationToken cancellationToken)
— RenamedCreateGroupRuleAsync(Okta.Sdk.IGroupRule groupRule, CancellationToken cancellationToken)DeleteRuleAsync(string ruleId, bool removeUsers, CancellationToken cancellationToken)
— Renamed with new signatureDeleteGroupRuleAsync(string ruleId, CancellationToken cancellationToken)GetRuleAsync(string ruleId, string expand, CancellationToken cancellationToken)
— RenamedGetGroupRuleAsync(string ruleId, string expand, CancellationToken cancellationToken)UpdateRuleAsync(Okta.Sdk.IGroupRule groupRule, string ruleId, CancellationToken cancellationToken)
— RenamedUpdateGroupRuleAsync(Okta.Sdk.IGroupRule groupRule, string ruleId, CancellationToken cancellationToken)ActivateRuleAsync(string ruleId, CancellationToken cancellationToken)
— RenamedActivateGroupRuleAsync(string ruleId, CancellationToken cancellationToken)DeactivateRuleAsync(string ruleId, CancellationToken cancellationToken)
— RenamedDeactivateGroupRuleAsync(string ruleId, CancellationToken cancellationToken)GetGroupAsync(string groupId, string expand, CancellationToken cancellationToken)
— Signature changedGetGroupAsync(string groupId, CancellationToken cancellationToken)ListGroupUsers(string groupId, string after, int limit, string managedBy)
— Signature changedListGroupUsers(string groupId, string after, int limit)RemoveGroupUserAsync(string groupId, string userId, CancellationToken cancellationToken)
— RenamedRemoveUserFromGroupAsync(string groupId, string userId, CancellationToken cancellationToken)
Okta.Sdk.PoliciesClient
ListPolicies(string type, string status, string after, int limit, string expand)
— Signature changedListPolicies(string type, string status, string expand)AddPolicyRuleAsync(Okta.Sdk.IPolicyRule policyRule, string policyId, bool activate, CancellationToken cancellationToken)
— Signature changedAddPolicyRuleAsync(Okta.Sdk.IPolicyRule policyRule, string policyId, CancellationToken cancellationToken)
Okta.Sdk.UserFactorsClient
AddFactorAsync(Okta.Sdk.IFactor factor, string userId, bool updatePhone, string templateId, int tokenLifetimeSeconds, bool activate, CancellationToken cancellationToken)
— Renamed with new signatureEnrollFactorAsync(Okta.Sdk.IUserFactor body, string userId, bool updatePhone, string templateId, int tokenLifetimeSeconds, bool activate, CancellationToken ca ncellationToken)ActivateFactorAsync(Okta.Sdk.IVerifyFactorRequest verifyFactorRequest, string userId, string factorId, CancellationToken cancellationToken)
— Renamed with new signatureActivateFactorAsync(Okta.Sdk.IActivateFactorRequest body, string userId, string factorId, CancellationToken cancellationToken)
Okta.Sdk.UsersClient
ListUsers(string q, string after, int limit, string filter, string format, string search, string expand)
— Signature changedListUsers(string q, string after, int limit, string filter, string search, string sortBy, string sortOrder)CreateUserAsync(Okta.Sdk.IUser user, bool activate, bool provider, Okta.Sdk.UserNextLogin nextLogin, CancellationToken cancellationToken)
— Signature changedCreateUserAsync(Okta.Sdk.ICreateUserRequest body, bool activate, bool provider, Okta.Sdk.UserNextLogin nextLogin, CancellationToken cancellationToken)ListAppLinks(string userId, bool showAll)
— Signature changedListAppLinks(string userId)ListUserGroups(string userId, string after, int limit)
— Signature changedListUserGroups(string userId)ExpirePasswordAsync(string userId, bool tempPassword, CancellationToken cancellationToken)
— Signature changedExpirePasswordAsync(string userId, CancellationToken cancellationToken)ResetAllFactorsAsync(string userId, CancellationToken cancellationToken)
— RenamedResetFactorsAsync(string userId, CancellationToken cancellationToken)ResetPasswordAsync(string userId, Okta.Sdk.AuthenticationProviderType provider, bool sendEmail, CancellationToken cancellationToken)
— Removed; instead use any of the following:ForgotPasswordGenerateOneTimeTokenAsync(string userId, bool sendEmail, CancellationToken cancellationToken)ForgotPasswordSetNewPasswordAsync(Okta.Sdk.IUserCredentials user, string userId, bool sendEmail, CancellationToken cancellationToken)ExpirePasswordAsync(string userId, CancellationToken cancellationToken)ExpirePasswordAndGetTemporaryPasswordAsync(string userId, CancellationToken cancellationToken)
ListAssignedRoles(string userId, string expand)
— RenamedListAssignedRolesForUser(string userId, string expand)EndAllUserSessionsAsync(string userId, bool oauthTokens, CancellationToken cancellationToken)
— RenamedClearUserSessionsAsync(string userId, bool oauthTokens, CancellationToken cancellationToken)
The following is a list of context specific clients that are new in version 3.0.0. Instances of each are available as properties of an OktaClient instance where the name of the property is the name of the type with the "Client" suffix removed.
Okta.Sdk.AuthorizationServersClient, see Authorization Servers API.Okta.Sdk.EventHooksClient, see Event Hooks Management API.Okta.Sdk.FeaturesClient, see Features API.Okta.Sdk.IdentityProvidersClient, see Identity Providers API.Okta.Sdk.InlineHooksClient, see Inline Hooks Management API.Okta.Sdk.LinkedObjectsClient, see Linked Objects API.Okta.Sdk.TemplatesClient, see Custom Templates API.Okta.Sdk.TrustedOriginsClient, see Trusted Origins API.Okta.Sdk.UserTypesClient, see User Types API.
The previous version of this library, Okta.Core.Client, has been rewritten from the ground up as Okta.Sdk (this project). This was done to improve stability and to add support for .NET Core alongside .NET Framework.
Because this was a breaking change, Okta.Sdk was published with version numbers starting from 1.0. The last published version of Okta.Core.Client is 0.3.3.
This library now supports a flexible configuration model that allows you to provide configuration in code, via a JSON or YAML file, or via environment variables.
The simplest way to construct a client is via code:
var client = new OktaClient(new OktaClientConfiguration
{
OrgUrl = "https://{{yourOktaDomain}}",
Token = "{{yourApiToken}}"
});In version 0.3.3, you had to create a new UsersClient() or call client.GetUsersClient() to get access to methods that operated on a User (for example). This has now been simplified to client.Users:
var vader = await client.Users.CreateUserAsync(...);The Users object acts as a collection, so you can also do:
var allUsers = await client.Users.ToArray();The readme in this repository contains a number of usage examples.
In version 1.0 and above, every method that makes a network call is Task-returning and awaitable. Use await when calling these methods, and avoid using .Result or .Wait() unless absolutely necessary.
In version 0.3.3, the AuthClient class provided the ability to call the Authentication API to log a user in with a username and password, or perform other tasks like enrolling and challenging factors during authentication. The object and security model of the Authentication API compared the rest of the management APIs (Users, Factors, Groups, etc.) is different enough that it made sense to split it into two libraries.
Starting with version 1.0, Authentication has been broken out into a separate library, the Okta .NET Authentication SDK.
Many applications can use our ASP.NET and ASP.NET Core middleware to log users in without needing to call the Authentication API directly, and we recommend only using the Authentication SDK in complex scenarios that can't be handled with the middleware or widget.
If you have questions about this library or about the Okta APIs, post a question on our Developer Forum.
If you find a bug or have a feature request for this library specifically, post an issue here on GitHub.