Click here to Skip to main content
15,745,335 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)

Below is the code I am using using for Twitter login.
But it generates the errors:
No overload for method 'GetAccessToken' takes 3 arguments
No overload for method 'GetRequestToken' takes 2 arguments

When I used like this
OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret);

then it shows the error
Cannot implicitly convert type 'Twitterizer.OAuthTokenResponse' to 'OAuthTokenResponse'

protected void imgbtnTwitter_Click(object sender, ImageClickEventArgs e)
	//  bool condition = forceLoginCheckbox.Checked;
	// add these to web.config or your preferred location
	var consumerKey = ConfigurationManager.AppSettings["consumerKey"];
	var consumerSecret = ConfigurationManager.AppSettings["consumerSecret"];

	if (Request.QueryString["oauth_token"] == null)
		//Step 1: Get Request Token
		OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret);

		//Step 2: Redirect User to Requested Token
		Response.Redirect("" + RequestToken.Token);
		//For Valid User
		string Oauth_Token = Request.QueryString["oauth_token"].ToString();

		var accessToken = OAuthUtility.GetAccessToken(consumerKey, consumerSecret, Oauth_Token);

Can anyone suggest better method for login with twitter.

Updated 1-Oct-11 11:26am

1 solution

Your first two errors are because you have passed too much or not enough arguments to GetRequestToken or GetAccessToken - look at how many they take! (If you can't work out what those errors mean, have you ever programmed before? I suggest you try something more simple if you're stuck on things like this.)

This is a bug with your code - types issue. Replace
OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret);


Twitterizer.OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret);

Hope this helps,

Ed :)
Share this answer
aryan2010 2-Oct-11 11:59am    
Hello Edward

I have tried your code but I have to use like this then it works properly.
Now I am able to redirect to Twitter. But I am now facing problem of callback.
After login through twitter it does not return to localhost.

Twitterizer.OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret,"oob");

For Your Support
Ed Nutting 2-Oct-11 12:36pm    
Of course it won't - how can the Twitter servers redirect to your localhost do you think? The answer is they can't - your site HAS TO BE PUBLICLY HOSTED so that the Twitter servers can actually redirect back to your site! For the Twitter servers, localhost is themselves just as localhost on your machine is your machine. Get yourself a testing server and a domain name and set up your site on that - redirecting will then work. Hope this helps, Ed :)

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