I have an elevated development account in Twitter.
I'm testing Tweetinvi with this code:
private async Task ConnectToTwitter()
{
// we create a client with your user's credentials
var userClient = new TwitterClient(ConsumerKey, ConsumerSecret, AccessToken, AccessTokenSecret);
toolStripStatusLabel1.Text = "Connected";
// request the user's information from Twitter API
var user = await userClient.Users.GetAuthenticatedUserAsync();
labelUserName.Text = user.Name;
// publish a tweet
var tweet = await userClient.Tweets.PublishTweetAsync("Hello tweetinvi world!");
Console.WriteLine("You published the tweet : " + tweet);
}
And I get this error:
Reason : Unauthorized
Code : 401
Date : 29/05/2022 15:25:49 +02:00
URL : https://api.twitter.com/1.1/statuses/update.json?status=Hello%20tweetinvi%20world%21&tweet_mode=extended
Twitter documentation description : Unauthorized - Authentication credentials were missing or incorrect.
On this line of code:
var tweet = await userClient.Tweets.PublishTweetAsync("Hello tweetinvi world!");
How can I add the credentials to the PublishTweetAsync call?
Or maybe, there is another way to publish a tweet with credentials without using PublishTweetAsync?
UPDATE
Due to the answer of Andy Piper, I have to say that the code compiles, so all the arguments for TwitterClient has a value (of course, I'm not going to share them here), and I can get the user here:
var user = await userClient.Users.GetAuthenticatedUserAsync();
But I don't know what to put in the Callback URI.

The answer is in your code…
You need to have the values defined in your code to pass in to the
TwitterClientinstance. You also need to ensure that you have an app with access to the v1.1 API (elevated access) to use this code, since it will not work with v2.Finally, you should check that your app has read and write permissions and that your access token and secret were generated with these permissions.