okta / okta-sdk-dotnet

A .NET SDK for interacting with the Okta management API, enabling server-side code to manage Okta users, groups, applications, and more.
Other
160 stars 100 forks source link

Lack of documentation for Event Hooks #534

Closed oyemini-fortifieddata closed 2 years ago

oyemini-fortifieddata commented 2 years ago

Hello, I tried to find some info on registering Event Hooks through the .Net SDK, I've only found this code example on the integration tests:


var createdEventHook = await _oktaClient.EventHooks.CreateEventHookAsync(
                new EventHook
                {
                    Name = testEventHookName,
                    Events = new EventSubscriptions
                    {
                        Type = EventType,
                        Items = new string[]
                        {
                            "user.lifecycle.create",
                            "user.lifecycle.activate",
                        },
                    },
                    Channel = new EventHookChannel
                    {
                        Type = "HTTP",
                        Version = "1.0.0",
                        Config = new EventHookChannelConfig
                        {
                            Uri = "https://www.example.com/eventHooks", 
                            Headers = new List<IEventHookChannelConfigHeader>
                            {
                                new EventHookChannelConfigHeader
                                {
                                    Key = "X-Test-Header",
                                    Value = "Test header value",
                                },
                            },
                            AuthScheme = new EventHookChannelConfigAuthScheme 
                            {
                                Type = "HEADER", 
                                Key = "Authorization",
                                Value = "Test-Api-Key", 
                            },
                        },
                    },
                });

Can u please explain and verify some of my question?

  1. Config.Uri => is this the URI that will be called when a new event is triggered
  2. Config.Headers.Key => what should I pass in here?
  3. Config.Headers.Value => what should I pass in here?
  4. AuthScheme => why should I pass an auth scheme if my _oktaClient object is already authenticated?
  5. AuthScheme.Value => // should I pass here my Okta API Token?
andriizhegurov-okta commented 2 years ago

Hi @oyemini-fortifieddata, please take a look at the Event Hooks Management API documentation.

From the doc:

Config.Uri => External service endpoint to call to execute the event hook handler Config.Headers => Optional list of key/value pairs for headers that should be sent with the request to the external service AuthScheme => The authentication scheme to use for this request (optional) AuthScheme.Value => The header value. This secret value is passed to your external service endpoint. Your external service can check for it as a security measure.

Hope this helps.