HELLLLP!!! "error while querying twitter" and "401" error

Dec 1, 2012 at 8:37 PM

I'd download asp.net sample, I go to web.config and put my twitterconsumerkey and twitterconsumersecret.

I have an application in twitter acount with read and write access.

It make me 401 error when I exectute the sample and I read in discussions that it could be that credentials not have the accesstoken and oauthtoken values, and that they have to be the same.

I put the value to this credentials.accesstoken = xxxx and credentials.oauthtoken = xxxx

The 401 error dissapear, and when all is ok, I received the error "error while querying twitter" in the line of var accounttotals = accounttotalsresults.tolist().

In the detail of this error I can see in httperror value "401 Unauthorized"

How can I do? I think all is correct

Sorry my English

thanks ......

Coordinator
Dec 1, 2012 at 9:38 PM

Hi,

There can be many reasons for a 401 Unauthorized error. I have a FAQ to help you step through the troubleshooting process:

http://linqtotwitter.codeplex.com/wikipage?title=LINQ%20to%20Twitter%20FAQ&referringTitle=Documentation

@JoeMayo

Dec 2, 2012 at 10:25 AM
Edited Dec 2, 2012 at 10:58 AM

Thanks JoeMayo I had check all, may be I can't see something, is curiosly that I have not problem in the first authentification, and is when I want to make a query when this error appear "error while querying twitter"

UPDATE: I have try the windows 8 metro sample, when I want to authentificate it say me to give authorithing to the application with a pin. I give it and all works fine. but in the asp demo I have the error. I have to give authentificate to the asp application with another pin?

In metro sample I only give costumerkey and costumersecret.

Thanks.

ok 

  • Are your credentials entered properly. Check for misspellings and potential copy and paste errors. You can double-check your credentials at the Twitter developer site (http://dev.twitter.com), explained in the previous item.

ok

  • Did you assign the right key to the right token. Make sure you didn't accidentally mix up your ConsumerTokenKey and ConsumerTokenSecret. You can verify your credentials at the Twitter developer site (http://dev.twitter.com)

ok

  • Make sure you've entered a Callback URL for your Twitter application at the Twitter developer site (http://dev.twitter.com).

http://www.sample.com

  • Check your access level at the Twitter developers site (http://dev.twitter.com). Potential settings are Read, Write, and Direct Message.

Read and write in oauth and in access token

  • Ensure your computer time is up-to-date. The Twitter server reads your OAuth signature (LINQ to Twitter prepares for you) and verifies the time used to build the signature. This time comes from your machine. If the time is off, your OAuth signature is considered invalid. Be aware that the Windows Phone emulator time may need to be reset every time the emulator boots up.

ok

  • Has Twitter disabled your credentials? If you post a message on the Twitter forums that exposes your credentials, Twitter will invalidate your credentials to secure your account. You can re-generate credentials at any time.

ok

  • Has Twitter revoked your application's access. If you've violated any Twitter rules, they might disable your application.

ok

  • Ensure you have permission to perform the operation you're attempting. i.e. Some features are in Beta and require permission. Other features, such as XAuth require permission from Twitter to use.

I'm trying the asp sample

  • Examine the API call you're trying to use and make sure you have permission to perform the action you're trying to perform. Consult the Twitter documentation (linked to from the bottom of each LINQ to Twitter API documentation page) for the latest details of how the API should be used.

I'm trying the asp sample

 

Coordinator
Dec 2, 2012 at 4:43 PM

For the ASP.NET example, you add ConsumerKey and ConsumerSecret to the Web.config. It's using WebAuthorizer, which doesn't use a pin. WebAuthorizer navigates the browser directing to the Twitter authorization page. After the user authorizes your app, Twitter redirects them back to your app.  The Complete authorization then executes and you can pull all four credentials from the authorizer there and reuse them for that user. Here's my documentation on OAuth that might help:

Securing Your Applications

@JoeMayo