Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET twitter
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 5-Mar-12 23:29pm
Comments
aspnet_regiis -i at 10-Oct-12 8:16am
   
Problem is with your API keys configuration
sameer.pantvaidya at 2-Sep-13 9:28am
   
I'm also getting same error.. any help??
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
AtifImtiaz at 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 at 6-Mar-12 23:40pm
   
thanx maulik you helped me alot. those links helped me on the issue i was asking
MaulikDusara at 7-Mar-12 0:04am
   
welcome
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

OAuthTokenResponse accessToken = OAuthUtility.GetAccessToken(consumer key, secret key, requestToken, txtPin.Text);
 

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

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 432
1 OriginalGriff 250
2 CPallini 240
3 Abdul Samad KP 145
4 George Jonsson 119
0 OriginalGriff 6,329
1 Sergey Alexandrovich Kryukov 5,700
2 CPallini 4,940
3 George Jonsson 3,469
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 10 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100