Okta Management SDKs may not implement all of the Okta API endpoints or may not pull in the attributes an application is interested in.
okta-sdk-dotnet provides a way to manually call these endpoints.
- okta-sdk-dotnet v6.x+
- REST API
Some of the Okta API endpoints may not be exposed in the SDKs, or may change and the latest SDK version has yet to account for this change. Being able to make direct calls to these API allows applications to continue to use the SDK for all management calls.
Below is a code snippet needed to make a call using the SDK.
using Newtonsoft.Json.Linq;
using Okta.Sdk.Api;
using Okta.Sdk.Client;
...
...
Okta.Sdk.Client.RequestOptions localVarRequestOptions = new Okta.Sdk.Client.RequestOptions();
localVarRequestOptions.HeaderParameters.Add("Content-Type", "application/json");
localVarRequestOptions.HeaderParameters.Add("Accept", "application/json");
localVarRequestOptions.PathParameters.Add("userId", "00u8mfo4xwwL88888888");
// Authorization header will be in form of 'Authorization: YOUR_API_KEY_HERE'
localVarRequestOptions.HeaderParameters.Add("Authorization", config.GetApiKeyWithPrefix("Authorization"));
var path = "/api/v1/users/{userId}/factors";
// I use ApplicationApi, but you can use any of the SDK APIs to get access to AsynchronousClient such as UserFactorApi
ApiResponse<JArray> localVarResponse = await appApi.AsynchronousClient.GetAsync<JArray>(path, localVarRequestOptions).ConfigureAwait(false);
foreach (JObject f in localVarResponse.Data)
{
Console.WriteLine("id: " + f.GetValue("id"));
Console.WriteLine(" name: " + f.GetValue("name"));
Console.WriteLine(" type: " + f.GetValue("type"));
Console.WriteLine(" key: " + f.GetValue("key"));
Console.WriteLine(" status: " + f.GetValue("status"));
Console.WriteLine(" link: " + f.GetValue("_links").ToObject<JObject>().GetValue("self").ToObject<JObject>().GetValue("href"));
Console.WriteLine("");
}
The response type will depend on the API used and should be cross-referenced with the Okta API documentation.
NOTE: If unfamiliar with curl, we recommend using Postman to help with the structure of the request.
Related References
Complete API documentation for Okta APIs can be found at:
