diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-31 22:01:16 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-07-31 22:01:16 -0700 |
commit | c94c7f8197eda673947a9d1e0c0b3f3c4efca94f (patch) | |
tree | 0f978cfc2de70c54ac81e11d4339da04dff9f27f /samples/OAuthConsumer/Yammer.aspx.cs | |
parent | 7d38eefb65928a1e80036ec006b0e129dc2cface (diff) | |
download | DotNetOpenAuth-c94c7f8197eda673947a9d1e0c0b3f3c4efca94f.zip DotNetOpenAuth-c94c7f8197eda673947a9d1e0c0b3f3c4efca94f.tar.gz DotNetOpenAuth-c94c7f8197eda673947a9d1e0c0b3f3c4efca94f.tar.bz2 |
Split the OAuthServiceProvider sample into two samples: OAuthAuthorizationServer and OAuthResourceServer.
Renamed OAuthConsumer to OAuthClient.
Diffstat (limited to 'samples/OAuthConsumer/Yammer.aspx.cs')
-rw-r--r-- | samples/OAuthConsumer/Yammer.aspx.cs | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/samples/OAuthConsumer/Yammer.aspx.cs b/samples/OAuthConsumer/Yammer.aspx.cs deleted file mode 100644 index d8993fe..0000000 --- a/samples/OAuthConsumer/Yammer.aspx.cs +++ /dev/null @@ -1,76 +0,0 @@ -namespace OAuthConsumer { - using System; - using System.Collections.Generic; - using System.Configuration; - using System.Linq; - using System.Web; - using System.Web.UI; - using System.Web.UI.WebControls; - using DotNetOpenAuth.ApplicationBlock; - using DotNetOpenAuth.Messaging; - using DotNetOpenAuth.OAuth; - - public partial class Yammer : System.Web.UI.Page { - private string RequestToken { - get { return (string)ViewState["YammerRequestToken"]; } - set { ViewState["YammerRequestToken"] = value; } - } - - private string AccessToken { - get { return (string)Session["YammerAccessToken"]; } - set { Session["YammerAccessToken"] = value; } - } - - private InMemoryTokenManager TokenManager { - get { - var tokenManager = (InMemoryTokenManager)Application["YammerTokenManager"]; - if (tokenManager == null) { - string consumerKey = ConfigurationManager.AppSettings["YammerConsumerKey"]; - string consumerSecret = ConfigurationManager.AppSettings["YammerConsumerSecret"]; - if (!string.IsNullOrEmpty(consumerKey)) { - tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); - Application["YammerTokenManager"] = tokenManager; - } - } - - return tokenManager; - } - } - - protected void Page_Load(object sender, EventArgs e) { - if (this.TokenManager != null) { - this.MultiView1.SetActiveView(this.BeginAuthorizationView); - } - } - - protected void getYammerMessages_Click(object sender, EventArgs e) { - var yammer = new WebConsumer(YammerConsumer.ServiceDescription, this.TokenManager); - } - - protected void obtainAuthorizationButton_Click(object sender, EventArgs e) { - var yammer = YammerConsumer.CreateConsumer(this.TokenManager); - string requestToken; - Uri popupWindowLocation = YammerConsumer.PrepareRequestAuthorization(yammer, out requestToken); - this.RequestToken = requestToken; - string javascript = "window.open('" + popupWindowLocation.AbsoluteUri + "');"; - this.Page.ClientScript.RegisterStartupScript(GetType(), "YammerPopup", javascript, true); - this.MultiView1.SetActiveView(this.CompleteAuthorizationView); - } - - protected void finishAuthorizationButton_Click(object sender, EventArgs e) { - if (!Page.IsValid) { - return; - } - - var yammer = YammerConsumer.CreateConsumer(this.TokenManager); - var authorizationResponse = YammerConsumer.CompleteAuthorization(yammer, this.RequestToken, this.yammerUserCode.Text); - if (authorizationResponse != null) { - this.accessTokenLabel.Text = HttpUtility.HtmlEncode(authorizationResponse.AccessToken); - this.MultiView1.SetActiveView(this.AuthorizationCompleteView); - } else { - this.MultiView1.SetActiveView(this.BeginAuthorizationView); - this.authorizationErrorLabel.Visible = true; - } - } - } -}
\ No newline at end of file |