IMPORTANT!! Project moved to GitHub https://github.com/ziyasal/TwitterOAuth

TwitterOAuth an openauth library for .net apps,
Sample usage exist in source code

Basic Usage

Add following configuration to appSettings below web.config file
<add key="Tw-ApiKey" value="your consumer key here"/>
<add key="Tw-AppSecret" value="your consumer secret here"/>
<add key="Tw-RedirectUri" value="your redirected uri here"/>
  • Setup Authentication Link (Button)
Markup
 <a href='http://twitter.com/oauth/authorize?<%=GetUrlParamters()%>'>Login with Twitter</a>

Code behind
protected string GetUrlParamters()
{
    ITwitterOAuthManager oAuthManager = new TwitterOAuthManager();
    return oAuthManager.GetUrlParameters();
 }
  • After Twitter redirected to referrer url,
Redirected page code behind

protected void Page_Load(object sender, EventArgs e)
{
     ITwitterOAuthManager oAuthManager = new TwitterOAuthManager();

     if (oAuthManager.CheckTwitterOAuthRequest(Request.QueryString))
     {
          TwitterBasicProfile result = oAuthManager.Authenticate(Request.QueryString);
          txtHtmlArea.InnerHtml = Server.HtmlEncode(result.ScreenName);
     }
}

Redirected page markup
 <div id="txtHtmlArea" runat="server"></div>

Last edited Dec 11, 2012 at 8:42 PM by ziyasal, version 11