Hi All,

I use TweetinviAPI 5 + TweetinviAPI.AspNetPlugin, I’m trying to add a webhook using C# code below:

var consumerOnlyCredentials = new ConsumerOnlyCredentials(Models.Twitter.Consumer_API_Key, Models.Twitter.Consumer_API_Secret, Models.Twitter.Bearer_Token);

var appClient = new TwitterClient(consumerOnlyCredentials);

var environments = await appClient.AccountActivity.GetAccountActivityWebhookEnvironmentsAsync();

// the sandbox environment is available within the free tier
var sandboxEnvironment = environments.Single(x => x.Name == “dev”);

Plugins.Add();

await appClient.AccountActivity.CreateAccountActivityWebhookAsync(“dev”, “https://app.example.com/v1/api/twitter”);

it has thrown an exception:

Forbidden - The request is understood, but it has been refused or access is not allowed. An accompanying error message will explain why. This code is used when requests are being denied due to update limits.

is it because I use the free version of Account Activity API?, can I ask to release it?

webhook registration must use user context credentials, in your code it uses app only credentials

Check the documentation

  1. Registers a webhook URL(officials developer docs)

Requires Authentication Yes (user context - all consumer and access tokens)

  1. Webhooks - Register(tweetinvi)

The docs like:

// request to register your url - a crc challenge will be received by your http server
await userClient.AccountActivity.CreateAccountActivityWebhookAsync("sandbox", "https://my-webook-url.ngrok.io");

Your’s:

await appClient.AccountActivity.CreateAccountActivityWebhookAsync(“dev”, “https://app.example.com/v1/api/twitter”);

You should use a userClient which is set up using user context authentication instead of appClient

2 Likes

Thnaks @gauloics
You are right!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.