Search code examples
c#twittertweetsharp

TweetSharp GetAccessToken method returns null but only sometimes


After receiving a callback with OauthVerifier and RequestToken from Twitter my app uses Tweetsharp to get the access token:

OAuthAccessToken accessToken = service.GetAccessToken(user.TwitterRequestToken.InnerRequestToken, oauth_verifier);

This works fine for most users but sometimes this method returns null without making a call to Twitter.


Solution

  • This problem is caused by a change to how Twitter stores UserID's, moving from 32bit integers to 64bit. This occurred on October 21st 2013. https://dev.twitter.com/blog/64-bit-twitter-user-idpocalypse

    Tweetsharp was last updated before this date and therefore still treats user id's as int and not long values. It seems someone has fixed the issue https://github.com/danielcrenna/tweetsharp/issues/139 but the change hasn't been passed to NUGET as the creator is no longer updating the package.

    Users who registered before the changes will have no trouble but other users who registered after will encounter the mentioned error.

    Hopefully, it will eventually be updated but in the meantime the best course of action is to use an unoffical TweetSharp package which includes the changes.

    Please Note: This unofficial package seems to introduce a lot of other problems too, may have to find another way around this.