Class OktaClient
A client that communicates with the Okta management API.
Inheritance
Implements
Inherited Members
Namespace: Okta.Sdk
Assembly: Okta.Sdk.dll
Syntax
public class OktaClient : IOktaClient
Examples
Initialize an OktaClient by passing configuration via code
var oktaClient = new OktaClient(new OktaClientConfiguration
{
OrgUrl = "https://dev-12345.oktapreview.com/",
Token = "my_api_token"
});
Constructors
OktaClient(OktaClientConfiguration, ILogger, ISerializer)
Initializes a new instance of the OktaClient class.
Declaration
public OktaClient(OktaClientConfiguration apiClientConfiguration = null, ILogger logger = null, ISerializer serializer = null)
Parameters
Type | Name | Description |
---|---|---|
OktaClientConfiguration | apiClientConfiguration | The client configuration. If |
Microsoft.Extensions.Logging.ILogger | logger | The logging interface to use, if any. |
ISerializer | serializer | The JSON serializer to use, if any. Using the |
OktaClient(OktaClientConfiguration, HttpClient, ILogger, IRetryStrategy, ISerializer)
Initializes a new instance of the OktaClient class using the specified System.Net.Http.HttpClient.
Declaration
public OktaClient(OktaClientConfiguration apiClientConfiguration, HttpClient httpClient, ILogger logger = null, IRetryStrategy retryStrategy = null, ISerializer serializer = null)
Parameters
Type | Name | Description |
---|---|---|
OktaClientConfiguration | apiClientConfiguration | The client configuration. If |
System.Net.Http.HttpClient | httpClient | The HTTP client to use for requests to the Okta API. |
Microsoft.Extensions.Logging.ILogger | logger | The logging interface to use, if any. |
IRetryStrategy | retryStrategy | The retry strategy interface to use, if any. |
ISerializer | serializer | The JSON serializer to use, if any. Using the |
OktaClient(IDataStore, OktaClientConfiguration, RequestContext)
Initializes a new instance of the OktaClient class.
Declaration
protected OktaClient(IDataStore dataStore, OktaClientConfiguration configuration, RequestContext requestContext)
Parameters
Type | Name | Description |
---|---|---|
IDataStore | dataStore | The IDataStore to use. |
OktaClientConfiguration | configuration | The client configuration. |
RequestContext | requestContext | The request context, if any. |
Remarks
This overload is used internally to create cheap copies of an existing client.
Properties
Applications
Gets a IApplicationsClient that interacts with the Okta Applications API.
Declaration
public IApplicationsClient Applications { get; }
Property Value
Type | Description |
---|---|
IApplicationsClient | A IApplicationsClient that interacts with the Okta Applications API. |
AuthorizationServers
Gets an IAuthorizationServersClient that interacts with the Okta Authorization Servers API.
Declaration
public IAuthorizationServersClient AuthorizationServers { get; }
Property Value
Type | Description |
---|---|
IAuthorizationServersClient | An IAuthorizationServersClient that interacts with the Okta Authorization Servers API. |
Configuration
Gets the configuration passed to this IOktaClient.
Declaration
public OktaClientConfiguration Configuration { get; }
Property Value
Type | Description |
---|---|
OktaClientConfiguration | The client configuration. |
Remarks
The configuration is immutable after the client is initialized. This property references a copy of the configuration.
Domains
Gets a IDomainsClient that interacts with the Okta Domains API.
Declaration
public IDomainsClient Domains { get; }
Property Value
Type | Description |
---|---|
IDomainsClient | A IDomainsClient that interacts with the Okta Domains API. |
EventHooks
Gets an IEventHooksClient that interacts with the Okta Event Hooks API.
Declaration
public IEventHooksClient EventHooks { get; }
Property Value
Type | Description |
---|---|
IEventHooksClient | An IEventHooksClient that interacts with the Okta Event Hooks API. |
Features
Gets a IFeaturesClient that interacts with the Okta Features API.
Declaration
public IFeaturesClient Features { get; }
Property Value
Type | Description |
---|---|
IFeaturesClient | A IFeaturesClient that interacts with the Okta Features API. |
Groups
Gets a IGroupsClient that interacts with the Okta Groups API.
Declaration
public IGroupsClient Groups { get; }
Property Value
Type | Description |
---|---|
IGroupsClient | A IGroupsClient that interacts with the Okta Groups API. |
IdentityProviders
Gets an IIdentityProvidersClient that interacts with the Okta Identity Providers API.
Declaration
public IIdentityProvidersClient IdentityProviders { get; }
Property Value
Type | Description |
---|---|
IIdentityProvidersClient | An IIdentityProvidersClient that interacts with the Okta Identity Providers API. |
InlineHooks
Gets an IInlineHooksClient that interacts with the Okta Inline Hooks API.
Declaration
public IInlineHooksClient InlineHooks { get; }
Property Value
Type | Description |
---|---|
IInlineHooksClient | An IInlineHooksClient that interacts with the Okta Inline Hooks API. |
LinkedObjects
Gets an ILinkedObjectsClient that interacts with the Okta Linked Objects API.
Declaration
public ILinkedObjectsClient LinkedObjects { get; }
Property Value
Type | Description |
---|---|
ILinkedObjectsClient | An ILinkedObjectsClient that interacts with the Okta Linked Objects API. |
Logs
Gets a ILogsClient that interacts with the Okta Logs API.
Declaration
public ILogsClient Logs { get; }
Property Value
Type | Description |
---|---|
ILogsClient | A ILogsClient that interacts with the Okta Logs API. |
NetworkZones
Gets a INetworkZonesClient that interacts with the Okta Network Zones API.
Declaration
public INetworkZonesClient NetworkZones { get; }
Property Value
Type | Description |
---|---|
INetworkZonesClient | A INetworkZonesClient that interacts with the Okta Network Zones API. |
Policies
Gets a IPoliciesClient that interacts with the Okta Policies API
Declaration
public IPoliciesClient Policies { get; }
Property Value
Type | Description |
---|---|
IPoliciesClient | A IPoliciesClient that interacts with the Okta Policies API. |
Sessions
Gets a ISessionsClient that interacts with the Okta Sessions API.
Declaration
public ISessionsClient Sessions { get; }
Property Value
Type | Description |
---|---|
ISessionsClient | A ISessionsClient that interacts with the Okta Sessions API. |
Templates
Gets a ITemplatesClient that interacts with the Okta Templates API.
Declaration
public ITemplatesClient Templates { get; }
Property Value
Type | Description |
---|---|
ITemplatesClient | A ITemplatesClient that interacts with the Okta Templates API. |
TrustedOrigins
Gets an ITrustedOriginsClient that interacts with the Okta Trusted Origins API.
Declaration
public ITrustedOriginsClient TrustedOrigins { get; }
Property Value
Type | Description |
---|---|
ITrustedOriginsClient | An ITrustedOriginsClient that interacts with the Okta Trusted Origins API. |
UserFactors
Gets a IUserFactorsClient that interacts with the Okta Factors API.
Declaration
public IUserFactorsClient UserFactors { get; }
Property Value
Type | Description |
---|---|
IUserFactorsClient | A IUserFactorsClient that interacts with the Okta Factors API. |
Users
Gets a IUsersClient that interacts with the Okta Users API.
Declaration
public IUsersClient Users { get; }
Property Value
Type | Description |
---|---|
IUsersClient | A IUsersClient that interacts with the Okta Users API. |
UserSchemas
Gets an IUserSchemasClient that interacts with the Okta Schemas API.
Declaration
public IUserSchemasClient UserSchemas { get; }
Property Value
Type | Description |
---|---|
IUserSchemasClient | An ILinkedObjectsClient that interacts with the Okta Schemas API. |
UserTypes
Gets a IUserTypesClient that interacts with the Okta User Types API.
Declaration
public IUserTypesClient UserTypes { get; }
Property Value
Type | Description |
---|---|
IUserTypesClient | A IUserTypesClient that interacts with the Okta User Types API. |
Methods
CreateScoped(RequestContext)
Creates a new IOktaClient scoped to the given request context.
Declaration
public IOktaClient CreateScoped(RequestContext requestContext)
Parameters
Type | Name | Description |
---|---|---|
RequestContext | requestContext | The request context |
Returns
Type | Description |
---|---|
IOktaClient | The new client. |
Remarks
This method is used to temporarily create a copy of the client in order to pass information about the current request to the Okta API.
DeleteAsync(HttpRequest, CancellationToken)
Deletes a resource by specifying the HTTP request options.
Declaration
public Task DeleteAsync(HttpRequest request, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
HttpRequest | request | The request options. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task that represents the asynchronous operation. |
Remarks
You typically only need to use this method if you are working with resources not natively handled by this library.
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |
DeleteAsync(String, CancellationToken)
Deletes a resource by URL.
Declaration
public Task DeleteAsync(string href, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | href | The resource URL. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task that represents the asynchronous operation. |
Remarks
You typically only need to use this method if you are working with resources not natively handled by this library.
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |
GetAsync<T>(HttpRequest, CancellationToken)
Gets a resource by specifying the HTTP request options, and deserializes it to a Resource type.
Declaration
public Task<T> GetAsync<T>(HttpRequest request, CancellationToken cancellationToken = default(CancellationToken))
where T : Resource, new()
Parameters
Type | Name | Description |
---|---|---|
HttpRequest | request | The request options. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | The deserialized resource. |
Type Parameters
Name | Description |
---|---|
T | The Resource type to deserialize the returned data to. |
Remarks
You typically only need to use this method if you are working with resources not natively handled by this library.
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |
GetAsync<T>(String, CancellationToken)
Gets a resource by URL and deserializes it to a Resource type.
Declaration
public Task<T> GetAsync<T>(string href, CancellationToken cancellationToken = default(CancellationToken))
where T : Resource, new()
Parameters
Type | Name | Description |
---|---|---|
System.String | href | The resource URL. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | The deserialized resource. |
Type Parameters
Name | Description |
---|---|
T | The Resource type to deserialize the returned data to. |
Remarks
You typically only need to use this method if you are working with resources not natively handled by this library.
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |
GetCollection<T>(HttpRequest)
Gets a collection of resources from the Okta API by URL.
Declaration
public CollectionClient<T> GetCollection<T>(HttpRequest request)
where T : IResource
Parameters
Type | Name | Description |
---|---|---|
HttpRequest | request | The request options. |
Returns
Type | Description |
---|---|
CollectionClient<T> | A collection that can be enumerated asynchronously. |
Type Parameters
Name | Description |
---|---|
T | The Resource type of the collection. |
GetCollection<T>(String)
Gets a collection of resources from the Okta API by URL.
Declaration
public CollectionClient<T> GetCollection<T>(string href)
where T : IResource
Parameters
Type | Name | Description |
---|---|---|
System.String | href | The collection URL. |
Returns
Type | Description |
---|---|
CollectionClient<T> | A collection that can be enumerated asynchronously. |
Type Parameters
Name | Description |
---|---|
T | The Resource type of the collection. |
GetCollectionClient<T>(HttpRequest)
Creates a new CollectionClient<T> given an initial HTTP request.
Declaration
protected CollectionClient<T> GetCollectionClient<T>(HttpRequest initialRequest)
where T : IResource
Parameters
Type | Name | Description |
---|---|---|
HttpRequest | initialRequest | The initial HTTP request. |
Returns
Type | Description |
---|---|
CollectionClient<T> | The collection client. |
Type Parameters
Name | Description |
---|---|
T | The collection client item type. |
PostAsync(HttpRequest, CancellationToken)
Posts data to an endpoint by specifying the HTTP request options.
Declaration
public Task PostAsync(HttpRequest request, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
HttpRequest | request | The request options. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task that represents the asynchronous operation. |
Remarks
You typically only need to use this method if you are working with resources not natively handled by this library.
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |
PostAsync(String, Object, CancellationToken)
Posts data to an endpoint by URL.
Declaration
public Task PostAsync(string href, object model, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | href | The endpoint URL. |
System.Object | model | The data to serialize and attach to the request body. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task that represents the asynchronous operation. |
Remarks
You typically only need to use this method if you are working with resources not natively handled by this library.
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |
PostAsync<TResponse>(HttpRequest, CancellationToken)
Posts data to an endpoint by specifying the HTTP request options, and deserializes the response payload to a Resource type.
Declaration
public Task<TResponse> PostAsync<TResponse>(HttpRequest request, CancellationToken cancellationToken = default(CancellationToken))
where TResponse : Resource, new()
Parameters
Type | Name | Description |
---|---|---|
HttpRequest | request | The request options. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResponse> | The deserialized response data. |
Type Parameters
Name | Description |
---|---|
TResponse | The Resource type to deserialize the returned data to. |
Remarks
You typically only need to use this method if you are working with resources not natively handled by this library.
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |
PostAsync<TResponse>(String, Object, CancellationToken)
Posts data to an endpoint by URL, and deserializes the response payload to a Resource type.
Declaration
public Task<TResponse> PostAsync<TResponse>(string href, object model, CancellationToken cancellationToken = default(CancellationToken))
where TResponse : Resource, new()
Parameters
Type | Name | Description |
---|---|---|
System.String | href | The endpoint URL. |
System.Object | model | The data to serialize and attach to the request body. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResponse> | The deserialized response data. |
Type Parameters
Name | Description |
---|---|
TResponse | The Resource type to deserialize the returned data to. |
Remarks
You typically only need to use this method if you are working with resources not natively handled by this library.
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |
PutAsync(HttpRequest, CancellationToken)
Puts data to an endpoint by specifying the HTTP request options.
Declaration
public Task PutAsync(HttpRequest request, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
HttpRequest | request | The endpoint URL. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task that represents the asynchronous operation. |
Remarks
You typically only need to use this method if you are working with resources not natively handled by this library.
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |
PutAsync(String, Object, CancellationToken)
Puts data to an endpoint by URL.
Declaration
public Task PutAsync(string href, object model, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | href | The endpoint URL. |
System.Object | model | The data to serialize and attach to the request body. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A Task that represents the asynchronous operation. |
Remarks
You typically only need to use this method if you are working with resources not natively handled by this library.
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |
PutAsync<TResponse>(HttpRequest, CancellationToken)
Puts data to an endpoint by specifying the HTTP request options, and deserializes the response payload to a Resource type.
Declaration
public Task<TResponse> PutAsync<TResponse>(HttpRequest request, CancellationToken cancellationToken = default(CancellationToken))
where TResponse : Resource, new()
Parameters
Type | Name | Description |
---|---|---|
HttpRequest | request | The request options. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResponse> | The deserialized response data. |
Type Parameters
Name | Description |
---|---|
TResponse | The Resource type to deserialize the returned data to. |
Remarks
You typically only need to use this method if you are working with resources not natively handled by this library.
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |
PutAsync<TResponse>(String, Object, CancellationToken)
Puts data to an endpoint by URL and deserializes the response payload to a Resource type.
Declaration
public Task<TResponse> PutAsync<TResponse>(string href, object model, CancellationToken cancellationToken = default(CancellationToken))
where TResponse : Resource, new()
Parameters
Type | Name | Description |
---|---|---|
System.String | href | The endpoint URL. |
System.Object | model | The data to serialize and attach to the request body. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResponse> | The deserialized response data. |
Type Parameters
Name | Description |
---|---|
TResponse | The Resource type to deserialize the returned data to. |
Exceptions
Type | Condition |
---|---|
OktaApiException | An API error occurred. |