Authenticate ok (I think), but then get "Could not auth. you"

Jun 29, 2013 at 5:13 AM
Hi there Joe Mayo, great API!!! Excellent stuff.

I was using the API very happily until the changes which require authentication before searching (all I want to do is automate searching of twitter with one user at once) (though I would like to multithread my .NET application to speed things up)

I have tried both the XAuthenticate method and SingleUserAuthoriser. In both instances, I get past auth.Authorize (and auth.IsAuthorized = true), but can't execute a search query. My error message is "Could not authenticate you", which I get when running the twitterCtx.Search instruction.

My code looks like this ----
            var auth2 = new SingleUserAuthorizer
            {
                Credentials = new InMemoryCredentials
                {
                    ConsumerKey = "5txOLhp8mb5K9WdnYSD??",
                    ConsumerSecret = "S2QrHJDeUOqMVgNSyHvbkpMAj7VWvgwaXKf6Qjphs??",
                    AccessToken = "7950952-rgyHvPFmUBGrP2qlXnPkj8qamhtYE5glfplDLBm??",
                    OAuthToken = "7950952-rgyHvPFmUBGrP2qlXnPkj8qamhtYE5glfplDLBm??"
                }
            };
            auth2.Authorize();

            using (var twitterCtx = new TwitterContext(auth2))
            {
                //Log
                twitterCtx.Log = Console.Out;

                var searchResponse =
                (from search in twitterCtx.Search
                 where search.Type == SearchType.Search &&
                       search.Query == "$BHP"
                 select search)
                .SingleOrDefault();
            }
With XAuthenticate I get the same thing, with the following setup
            var auth = new XAuthAuthorizer
            {
                Credentials = new XAuthCredentials
                {
                    ConsumerKey = "5txOLhp8mb5K9WdnYSD??",
                    ConsumerSecret = "S2QrHJDeUOqMVgNSyHvbkpMAj7VWvgwaXKf6Qjphs??",
                    AccessToken = "7950952-rgyHvPFmUBGrP2qlXnPkj8qamhtYE5glfplDLBm??",
                    OAuthToken = "7950952-rgyHvPFmUBGrP2qlXnPkj8qamhtYE5glfplDLBm??",
                    UserName = "@billybond",
                    Password = "???????"
                }
            };
What could I be doing wrong???
Coordinator
Jun 29, 2013 at 2:07 PM
Hi,

First thing to do - you should go back to your Twitter app and re-generate your keys because now everyone can see what they are and your application is no longer secure.

The credentials in your SingleUserAuthorizer aren't set correctly. Go to your Twitter app and copy AccessToken into OAuthToken and copy AccessTokenSecret into AccessToken. I know, it's confusing, but the property names were set a long time ago and changed along the way.

XAuthAuthorizer requires permission from Twitter to use.

There's a new authorizer too, called ApplicationOnlyAuthorizer that works like this:
            var auth = new ApplicationOnlyAuthorizer
            {
                Credentials = new InMemoryCredentials
                {
                    ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"],
                    ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"]
                }
            };

            auth.Authorize();
@JoeMayo
Jun 30, 2013 at 2:31 AM
Joe-
Thanks for the advice - now works well.
Actually censored those keys above with some questionmarks - would not be so silly as to post the real ones.
Thanks a lot for the help,
Donald