The remote server returned an error: (401) Unauthorized.

Jul 27, 2011 at 7:05 PM
Edited Jul 27, 2011 at 7:06 PM


I would like to start following twitters, and do this with your code:
twitterCtx.CreateFriendship(string.Empty, entry.Author.Name, string.Empty, true);

I have added all info I know:
// configure the OAuth object
var auth = new XAuthAuthorizer {
    Credentials = new XAuthCredentials {
        ConsumerKey = "--",
        ConsumerSecret = "--",
        OAuthToken = "--",
        AccessToken = "--",
        UserName = "--",
        Password = "--"



I can search Twitter, I see that auth.IsAuthorized is true, however when I try to add a user to follow then I get this message:

The remote server returned an error: (401) Unauthorized.

Inside the Twitter API settings I have set this option:

Read, Write and Access direct messages

However, the details page with the token settings still say:

Access level Read-only

Do you have a suggestion for me?


Jul 27, 2011 at 7:51 PM


I can't do anything about Twitter's site, but you'll definitely need to give your app higher access than read-only.  Also, you need Twitter's permission to use XAuthAuthorizer.  For information on how to use XAuthAuthorizer, download the LINQ to Twitter Source code and look at the Program.cs file in the LinqToTwitterDemo project.


Jul 27, 2011 at 10:14 PM

Thank you Joe. Re-reading the docs, re-setting the Twitter settings (somehow the access settings now did changed), and re-coding the script made it work.