Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,
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

using Twitterizer;

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?
Posted
Comments
bbirajdar 10-Oct-12 8:16am    
Problem is with your API keys configuration
sameer.pantvaidya 2-Sep-13 9:28am    
I'm also getting same error.. any help??

 
Share this answer
 
Comments
AtifImtiaz 6-Mar-12 6:11am    
nice links but i have already gone through them. I Need to know the cause of that damn exception, its spoiling my mood :(
AtifImtiaz 6-Mar-12 23:40pm    
thanx maulik you helped me alot. those links helped me on the issue i was asking
[no name] 7-Mar-12 0:04am    
welcome
OAuthTokenResponse accessToken = OAuthUtility.GetAccessToken(consumer key, secret key, requestToken, txtPin.Text);


use above function with 3 parameters only.(remove txtPin.Text)
its will run.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900