"Parameter name: You must provide a consumerKey."

Nov 27, 2013 at 4:28 AM
I am a beginner programmer trying to figure out out to perform a search for Tweets. I am getting the error: "consumerKey\r\nParameter name: You must provide a consumerKey.".

My code is: (note: I added the appropriate token/key values where needed)
           var auth = new SingleUserAuthorizer
            {
                Credentials = new SingleUserInMemoryCredentials
                {
                    ConsumerKey = ConfigurationManager.AppSettings["-"],
                    ConsumerSecret = ConfigurationManager.AppSettings["-"],
                    OAuthToken = ConfigurationManager.AppSettings["-"],
                    AccessToken = ConfigurationManager.AppSettings["-"]
                }


            using (var twitterCtx = new TwitterContext(auth))
            {

                var srch =
                    (from search in twitterCtx.Search
                     where search.Type == SearchType.Search &&
                           search.Query == "LINQ to Twitter" &&
                           search.Count == 7
                     select search)
                    .SingleOrDefault();

                Console.WriteLine("\nQuery: {0}\n", srch.SearchMetaData.Query);
                srch.Statuses.ForEach(entry =>
                    Console.WriteLine(
                        "ID: {0, -15}, Source: {1}\nContent: {2}\n",
                        entry.StatusID, entry.Source, entry.Text));
any suggestions?
Coordinator
Nov 27, 2013 at 7:33 AM
Hi,

Look at what you're assigning to ConsumerKey. It looks like the appSettings name, "-", isn't valid:

ConfigurationManager.AppSettings["-"]

This has to match an entry in your *.config file in the <appSettings> section. Check out the downloadable source code and observe how appSettings is set up. You assign your tokens to the values there and that lets ConfigurationManager.AppSettings["twitterConsumerKey"] read it, assuming you have a key set to "twitterConsumerKey" with the value set to your consumer key that you got from Twitter.

Here are the docs for a little more help:

https://linqtotwitter.codeplex.com/wikipage?title=Securing%20Your%20Applications&referringTitle=Documentation

@JoeMayo on Twitter