I want to integrate twitter in my ASP.Net web site, C# is my code behind language.
I want to implement a profile page in which user should be able to sign in from twitter. After clicking on "Sign Up via Twitter" Button. I have made a twitter application and i am doing this thing with OAuth. After getting user details i want to add them to my SQL Server Database(So that in future user can sign in using these details). I am using the below code
1. string requestToken = OAuthUtility.GetRequestToken(consumer key, secret key, "Path of my localhost in which i want to call back").Token;
2. OAuthTokenResponse accessToken = OAuthUtility.GetAccessToken(consumer key, secret key, requestToken, txtPin.Text);
3. OAuthTokens tokens = new OAuthTokens();
4. tokens.AccessToken = accessToken.Token;
5. tokens.AccessTokenSecret = accessToken.TokenSecret;
6. tokens.ConsumerKey = consumer key of my twitter application
7. tokens.ConsumerSecret = consumer secret of my twitter application
8. screenName = accessToken.ScreenName;
9. userID = accessToken.UserId;
Now when i build the solution it build successfully, but gives an exception at runtime. The exception comes at Line # 2. The exception is
=> The remote server returned an error: (401) Unauthorized.
I have already search all around on the internet, so please answer if you have done this kind of stuff, am i doing something wrong here?