string callbackUrl = string.Format("{0}://{1}{2}/callback.aspx", this.Request.Url.Scheme, this.Request.Url.Authority, this.Request.ApplicationPath);
OAuthTokenResponse tr = OAuthUtility.GetRequestToken(consumerKey.Trim(), consumerSecretKey.Trim(), callbackUrl);
Uri authUri = OAuthUtility.BuildAuthorizationUri(tr.Token);
Session["token"] = tr;
Session["authUri"] = authUri;
string script = "<script type='text/javascript'>window.open('" + callbackUrl + "', 'TwitteroAuth', 'status=1, location=1, resizable=0, width=800, height=400');</script>"; Page.RegisterClientScriptBlock("oAuthWindow", script);
verifier = Request.QueryString["oauth_verifier"].ToString();
if (Session["token"] != null)
{
OAuthTokenResponse rsp = (OAuthTokenResponse)Session["token"];
OAuthTokenResponse accessToken = OAuthUtility.GetAccessToken(consumerKey.Trim(), consumerSecretKey.Trim(), rsp.Token, verifier);
OAuthTokens token = new OAuthTokens();
token.AccessToken = accessToken.Token;
token.AccessTokenSecret = accessToken.TokenSecret;
token.ConsumerKey = consumerKey;
token.ConsumerSecret = consumerSecretKey;
redirectUrl = string.Format("{0}://{1}{2}/default.aspx?token={3}&secret={4}&screen={5}", this.Request.Url.Scheme, this.Request.Url.Authority, this.Request.ApplicationPath, accessToken.Token, accessToken.TokenSecret, accessToken.ScreenName);
string script = "<script type=\"text/javascript\">var openerWindow = window.opener; openerWindow.location = \" "+redirectUrl+"\"; window.close();</script>";
Page.RegisterClientScriptBlock("oAuthReturn", script);
}
There are times when you find that in a particular situation you
cannot accomplish what you want given the features, permissions, and
terms you're given. That is not an invitation to go around them to
still find a way to accomplish your goals.
Thanks,
Taylor
> --
> Twitter developer documentation and resources: http://dev.twitter.com/doc
> API updates via Twitter: http://twitter.com/twitterapi
> Issues/Enhancements Tracker:
> http://code.google.com/p/twitter-api/issues/list
> Change your membership to this group:
> http://groups.google.com/group/twitter-development-talk
>