summaryrefslogtreecommitdiffstats
path: root/samples/OAuthClient
diff options
context:
space:
mode:
Diffstat (limited to 'samples/OAuthClient')
-rw-r--r--samples/OAuthClient/OAuthClient.csproj8
-rw-r--r--samples/OAuthClient/Twitter.aspx35
-rw-r--r--samples/OAuthClient/Twitter.aspx.cs101
-rw-r--r--samples/OAuthClient/Twitter.aspx.designer.cs78
4 files changed, 0 insertions, 222 deletions
diff --git a/samples/OAuthClient/OAuthClient.csproj b/samples/OAuthClient/OAuthClient.csproj
index 4ff85d3..61b3a79 100644
--- a/samples/OAuthClient/OAuthClient.csproj
+++ b/samples/OAuthClient/OAuthClient.csproj
@@ -97,7 +97,6 @@
<Content Include="SampleWcf2.aspx" />
<Content Include="SignInWithTwitter.aspx" />
<Content Include="TracePage.aspx" />
- <Content Include="Twitter.aspx" />
<Content Include="Web.config" />
<None Include="Service References\SampleResourceServer\DataApi1.xsd">
<SubType>Designer</SubType>
@@ -156,10 +155,6 @@
<Compile Include="TracePage.aspx.designer.cs">
<DependentUpon>TracePage.aspx</DependentUpon>
</Compile>
- <Compile Include="Twitter.aspx.cs">
- <DependentUpon>Twitter.aspx</DependentUpon>
- <SubType>ASPXCodeBehind</SubType>
- </Compile>
<Compile Include="Code\Logging.cs" />
<Compile Include="Code\TracePageAppender.cs" />
<Compile Include="GoogleAddressBook.aspx.cs">
@@ -167,9 +162,6 @@
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Twitter.aspx.designer.cs">
- <DependentUpon>Twitter.aspx</DependentUpon>
- </Compile>
<Compile Include="WindowsLive.aspx.cs">
<DependentUpon>WindowsLive.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
diff --git a/samples/OAuthClient/Twitter.aspx b/samples/OAuthClient/Twitter.aspx
deleted file mode 100644
index cb60851..0000000
--- a/samples/OAuthClient/Twitter.aspx
+++ /dev/null
@@ -1,35 +0,0 @@
-<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" Inherits="OAuthClient.Twitter" Codebehind="Twitter.aspx.cs" %>
-
-<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
-</asp:Content>
-<asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="Server">
- <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
- <asp:View ID="View1" runat="server">
- <h2>Twitter setup</h2>
- <p>A Twitter client app must be endorsed by a Twitter user. </p>
- <ol>
- <li><a target="_blank" href="https://twitter.com/oauth_clients">Visit Twitter and create
- a client app</a>. </li>
- <li>Modify your web.config file to include your consumer key and consumer secret.</li>
- </ol>
- </asp:View>
- <asp:View runat="server">
- <h2>Updates</h2>
- <p>Ok, Twitter has authorized us to download your feeds. Notice how we never asked
- you for your Twitter username or password. </p>
- <p>
- Upload a new profile photo:
- <asp:FileUpload ID="profilePhoto" runat="server" />
- &nbsp;<asp:Button ID="uploadProfilePhotoButton" runat="server"
- onclick="uploadProfilePhotoButton_Click" Text="Upload photo" />
- &nbsp;<asp:Label ID="photoUploadedLabel" runat="server" EnableViewState="False"
- Text="Done!" Visible="False"></asp:Label>
- </p>
- <p>
- Click &#39;Get updates&#39; to download updates to this sample.
- </p>
- <asp:Button ID="downloadUpdates" runat="server" Text="Get updates" OnClick="downloadUpdates_Click" />
- <asp:PlaceHolder runat="server" ID="resultsPlaceholder" />
- </asp:View>
- </asp:MultiView>
-</asp:Content>
diff --git a/samples/OAuthClient/Twitter.aspx.cs b/samples/OAuthClient/Twitter.aspx.cs
deleted file mode 100644
index 2ef5ab8..0000000
--- a/samples/OAuthClient/Twitter.aspx.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-namespace OAuthClient {
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Xml.Linq;
- using System.Xml.XPath;
- using DotNetOpenAuth.ApplicationBlock;
- using DotNetOpenAuth.OAuth;
-
- using DotNetOpenAuth.Messaging;
-
- public partial class Twitter : System.Web.UI.Page {
- private string AccessToken {
- get { return (string)Session["TwitterAccessToken"]; }
- set { Session["TwitterAccessToken"] = value; }
- }
-
- private InMemoryTokenManager TokenManager {
- get {
- var tokenManager = (InMemoryTokenManager)Application["TwitterTokenManager"];
- if (tokenManager == null) {
- string consumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"];
- string consumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"];
- if (!string.IsNullOrEmpty(consumerKey)) {
- tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret);
- Application["TwitterTokenManager"] = tokenManager;
- }
- }
-
- return tokenManager;
- }
- }
-
- protected async void Page_Load(object sender, EventArgs e) {
- if (this.TokenManager != null) {
- this.MultiView1.ActiveViewIndex = 1;
-
- if (!IsPostBack) {
- var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager);
-
- // Is Twitter calling back with authorization?
- var accessTokenResponse = await twitter.ProcessUserAuthorizationAsync(new HttpRequestWrapper(Request), Response.ClientDisconnectedToken);
- if (accessTokenResponse != null) {
- this.AccessToken = accessTokenResponse.AccessToken;
- } else if (this.AccessToken == null) {
- // If we don't yet have access, immediately request it.
- var request = await twitter.PrepareRequestUserAuthorizationAsync(Response.ClientDisconnectedToken);
- var response = await twitter.Channel.PrepareResponseAsync(request, Response.ClientDisconnectedToken);
- await response.SendAsync(new HttpResponseWrapper(Response), Response.ClientDisconnectedToken);
- }
- }
- }
- }
-
- protected async void downloadUpdates_Click(object sender, EventArgs e) {
- var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager);
- XPathDocument updates = new XPathDocument((await TwitterConsumer.GetUpdatesAsync(twitter, this.AccessToken, Response.ClientDisconnectedToken)).CreateReader());
- XPathNavigator nav = updates.CreateNavigator();
- var parsedUpdates = from status in nav.Select("/statuses/status").OfType<XPathNavigator>()
- where !status.SelectSingleNode("user/protected").ValueAsBoolean
- select new {
- User = status.SelectSingleNode("user/name").InnerXml,
- Status = status.SelectSingleNode("text").InnerXml,
- };
-
- StringBuilder tableBuilder = new StringBuilder();
- tableBuilder.Append("<table><tr><td>Name</td><td>Update</td></tr>");
-
- foreach (var update in parsedUpdates) {
- tableBuilder.AppendFormat(
- "<tr><td>{0}</td><td>{1}</td></tr>",
- HttpUtility.HtmlEncode(update.User),
- HttpUtility.HtmlEncode(update.Status));
- }
- tableBuilder.Append("</table>");
- this.resultsPlaceholder.Controls.Add(new Literal { Text = tableBuilder.ToString() });
- }
-
- protected async void uploadProfilePhotoButton_Click(object sender, EventArgs e) {
- if (this.profilePhoto.PostedFile.ContentType == null) {
- this.photoUploadedLabel.Visible = true;
- this.photoUploadedLabel.Text = "Select a file first.";
- return;
- }
-
- var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager);
- XDocument imageResult = await TwitterConsumer.UpdateProfileImageAsync(
- twitter,
- this.AccessToken,
- this.profilePhoto.PostedFile.InputStream,
- this.profilePhoto.PostedFile.ContentType,
- Response.ClientDisconnectedToken);
- this.photoUploadedLabel.Visible = true;
- }
- }
-} \ No newline at end of file
diff --git a/samples/OAuthClient/Twitter.aspx.designer.cs b/samples/OAuthClient/Twitter.aspx.designer.cs
deleted file mode 100644
index e82f477..0000000
--- a/samples/OAuthClient/Twitter.aspx.designer.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace OAuthClient {
-
-
- public partial class Twitter {
-
- /// <summary>
- /// MultiView1 control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.MultiView MultiView1;
-
- /// <summary>
- /// View1 control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.View View1;
-
- /// <summary>
- /// profilePhoto control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.FileUpload profilePhoto;
-
- /// <summary>
- /// uploadProfilePhotoButton control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.Button uploadProfilePhotoButton;
-
- /// <summary>
- /// photoUploadedLabel control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.Label photoUploadedLabel;
-
- /// <summary>
- /// downloadUpdates control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.Button downloadUpdates;
-
- /// <summary>
- /// resultsPlaceholder control.
- /// </summary>
- /// <remarks>
- /// Auto-generated field.
- /// To modify move field declaration from designer file to code-behind file.
- /// </remarks>
- protected global::System.Web.UI.WebControls.PlaceHolder resultsPlaceholder;
- }
-}