I am currently developing a timer job that executes on intervals and captures tweets and direct messages from specific twitter handles used by our organization principals for records retention purposes. My timer job is currently able to capture and archive my tweets from my own personal twitter handle which I use it to test with for now. However, I’m not able to capture and archive any direct messages due to the error, “Client is not permitted to perform this action”. Based on my research on the web, I found out that my application has to be whitelisted first before my application can receive my direct messages. Is this correct? If so, then how do I get whitelisted?
This works for capturing my tweets:
var auth = new SingleUserAuthorizer
{
CredentialStore = new SingleUserInMemoryCredentialStore
{
ConsumerKey = oauth_consumer_key,
ConsumerSecret = oauth_consumer_secret,
AccessToken = oauth_token,
AccessTokenSecret = oauth_token_secret
}
}
And this does not work:
var auth = new XAuthAuthorizer
{
CredentialStore = new XAuthCredentials
{
ConsumerKey = oauth_consumer_key,
ConsumerSecret = oauth_consumer_secret,
UserName = "....._._......", // <--- Obviously I have masked the twitter handle and password for the purpose of posting it here....
Password = "............"
}
};
Task authTask = auth.AuthorizeAsync();
authTask.Wait();
With this, I get the following exception…
InnerException:
ErrorCode=0
HResult=-2146233088
Message=<?xml version="1.0" encoding="UTF-8"?><errors><error code="87">Client is not permitted to perform this action</error></errors>
ReasonPhrase=Forbidden
Source=LinqToTwitter.net
StackTrace:
at LinqToTwitter.Net.TwitterErrorHandler.BuildAndThrowTwitterQueryException(String responseStr, HttpResponseMessage msg)
at LinqToTwitter.Net.TwitterErrorHandler.<HandleGenericErrorAsync>d__1.MoveNext()