Here is the screenshot of debug sessions and below is the code
public async Task SubscribeAsync(TwitchSubscriptionContext context, CancellationToken cancellationToken)
{
context.ThrowIfNull(nameof(context));
context.Callback.ThrowIfNullOrWhiteSpace(nameof(context.Callback));
var subscriptionPayLoad = new TwitchSubscription(context.StreamerMetadataId, this.clientSecret, context.Action, context.LeaseSeconds, context.Callback);
using (StringContent requestBody = TwitchClient.CreateJsonContent(subscriptionPayLoad.ToJson()))
{
using (var clientBuilder = new RestClientBuilder())
{
await this.AddCredentialHeadersAsync(clientBuilder, cancellationToken);
var client = clientBuilder.Build();
var requestUri = new Uri(TwitchClient.WebooksUrl);
var response = await client.PostAsync(requestUri, requestBody, cancellationToken);
if (response?.Content == null || !response.IsSuccessStatusCode)
{
return null;
}
return new SubscriptionInfo()
{
Subscribed = true,
ExpirationDateTime = DateTime.UtcNow.AddSeconds(subscriptionPayLoad.LeaseSeconds),
StartDateTime = DateTime.UtcNow,
};
}
}
}
