null objects but valid tokens from login

Oct 17, 2014 at 10:50 PM
Hi, we're using the Microsoft.AspNet.Identity framework to handle Twitter accounts and logins. We are successfully logging users in and getting an Access Token and Access Token Secret, but when we pass those, along with the Consumer Key/Secret (which we're successfully using during the login to get the access tokens) into your Credentials and make any requests, we're getting a NULL back.

Here are two examples:
var cred = TwitterCredentials.CreateCredentials(twitterAccessToken, twitterAccessTokenSecret, twitterConsumerKey, twitterConsumerSecret);
TwitterCredentials.ExecuteOperationWithCredentials(cred, () =>
{
    var tweet = Tweet.PublishTweet(tweetStatus);
    comment.TwitterStatusId = tweet.IdStr;
});
and
ILoggedUser loggedUser = null;
var cred = TwitterCredentials.CreateCredentials(accessToken, accessTokenSecret, twitterConsumerKey, twitterConsumerSecret));
TwitterCredentials.ExecuteOperationWithCredentials(cred, () =>
{
    loggedUser = Tweetinvi.User.GetLoggedUser();
});
In both cases, while debugging, I can see that the "cred" object has all four values correctly, but in both cases, the "tweet" and "loggedUser" objects are returned null.

I'm not sure what to troubleshoot to figure out why they're returning null. Are the credentials somehow wrong? We have our App permissions set to Read/Write.

Any help would be much appreciated!

Thanks.
Oct 20, 2014 at 5:40 PM
Hello there,

Please give me the result of the ExceptionHandller.GetLastException() after you requested your logged user (Tweetinvi.User.GetLoggedUser();).
Exception Handler Documentation

Regards,
Linvi
Oct 20, 2014 at 7:17 PM
StatusCode: 401, Details: "Could not authenticate you"

And I tried to serialize the exception object itself in case that was helpful:
{"ClassName":"Tweetinvi.Logic.Exceptions.TwitterException","Message":"Operation is not valid due to the current state of the object.","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":" at Tweetinvi.WebLogic.WebRequestExecutor.ExecuteWebRequest(HttpWebRequest httpWebRequest)\r\n at Tweetinvi.WebLogic.TwitterRequester.ExecuteQuery(String url, HttpMethod httpMethod, IEnumerable`1 headers)\r\n at Tweetinvi.Credentials.TwitterAccessor.ExecuteQuery(String query, HttpMethod method)","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":"8\nExecuteWebRequest\nTweetinvi.WebLogic, Version=0.9.3.3, Culture=neutral, PublicKeyToken=null\nTweetinvi.WebLogic.WebRequestExecutor\nSystem.String ExecuteWebRequest(System.Net.HttpWebRequest)","HResult":-2146233079,"Source":"Tweetinvi.WebLogic","WatsonBuckets":null}

The access token and access secret have just been returned via the login window using the same consumer key and consumer secret, so I don't understand why it would think it can't authenticate us?
Oct 21, 2014 at 7:29 PM
Okay, nevermind, there was a weird config error and the wrong consumer keys were being passed in. Sorry!
Marked as answer by linvi on 10/21/2014 at 1:03 PM