Sam
Sam

Reputation: 4484

Unable to authenticate users via Twitter from Microsoft AspNet OAuth lib

I am using Microsoft AspNet OAuth library (which references DotNetOpenAuth) to authenticate users via Twitter on my site. I am passing correct api key and secret while registering twitter client (OAuthWebSecurity.RegisterTwitterClient), but still I get the below error message on requesting authentication (OAuthWebSecurity.RequestAuthentication) -

An exception of type 'DotNetOpenAuth.Messaging.ProtocolException' occurred in DotNetOpenAuth.Core.dll but was not handled in user code

Additional information: Error occurred while sending a direct message or getting the response.

InnerException: {"The remote server returned an error: (401) Unauthorized."}

I have earlier made calls to Twitter API using same key and secret and never found any problems. Not sure why this is not working with OAuth library. Can someone tell me what could be causing this and how to go about resolving it? Any help will be appreciated.

Upvotes: 0

Views: 789

Answers (1)

Sam
Sam

Reputation: 4484

Finally found the solution to the problem.

I needed to provide a callback URL in the Twitter app settings. I didn't provide it earlier while registering as the application was running in localhost. But, luckily Twitter doesn't have problem providing any dummy URL as callback URL, which I now did. And it works!

Upvotes: 2

Related Questions