Click here to Skip to main content
13,148,214 members (53,049 online)
Rate this:
 
Please Sign up or sign in to 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 5-Mar-12 23:29pm
Comments
aspnet_regiis -i 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??
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
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
MaulikDusara 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
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.170924.2 | Last Updated 10 Oct 2012
Copyright © CodeProject, 1999-2017
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