summaryrefslogtreecommitdiffstats
path: root/samples/OAuthConsumer
diff options
context:
space:
mode:
Diffstat (limited to 'samples/OAuthConsumer')
-rw-r--r--samples/OAuthConsumer/App_Code/InMemoryTokenManager.cs22
-rw-r--r--samples/OAuthConsumer/Twitter.aspx16
-rw-r--r--samples/OAuthConsumer/Twitter.aspx.cs16
-rw-r--r--samples/OAuthConsumer/Web.config8
4 files changed, 37 insertions, 25 deletions
diff --git a/samples/OAuthConsumer/App_Code/InMemoryTokenManager.cs b/samples/OAuthConsumer/App_Code/InMemoryTokenManager.cs
index fede300..120f00a 100644
--- a/samples/OAuthConsumer/App_Code/InMemoryTokenManager.cs
+++ b/samples/OAuthConsumer/App_Code/InMemoryTokenManager.cs
@@ -28,14 +28,6 @@ public class InMemoryTokenManager : IConsumerTokenManager {
#region ITokenManager Members
- public string GetConsumerSecret(string consumerKey) {
- if (consumerKey == this.ConsumerKey) {
- return this.ConsumerSecret;
- } else {
- throw new ArgumentException("Unrecognized consumer key.", "consumerKey");
- }
- }
-
public string GetTokenSecret(string token) {
return this.tokensAndSecrets[token];
}
@@ -44,20 +36,6 @@ public class InMemoryTokenManager : IConsumerTokenManager {
this.tokensAndSecrets[response.Token] = response.TokenSecret;
}
- /// <summary>
- /// Checks whether a given request token has already been authorized
- /// by some user for use by the Consumer that requested it.
- /// </summary>
- /// <param name="requestToken">The Consumer's request token.</param>
- /// <returns>
- /// True if the request token has already been fully authorized by the user
- /// who owns the relevant protected resources. False if the token has not yet
- /// been authorized, has expired or does not exist.
- /// </returns>
- public bool IsRequestTokenAuthorized(string requestToken) {
- throw new NotImplementedException();
- }
-
public void ExpireRequestTokenAndStoreNewAccessToken(string consumerKey, string requestToken, string accessToken, string accessTokenSecret) {
this.tokensAndSecrets.Remove(requestToken);
this.tokensAndSecrets[accessToken] = accessTokenSecret;
diff --git a/samples/OAuthConsumer/Twitter.aspx b/samples/OAuthConsumer/Twitter.aspx
index a659533..30ce2a0 100644
--- a/samples/OAuthConsumer/Twitter.aspx
+++ b/samples/OAuthConsumer/Twitter.aspx
@@ -16,9 +16,19 @@
</asp:View>
<asp:View runat="server">
<h2>Updates</h2>
- <p>Ok, Twitter has authorized us to download your feeds. Click 'Get updates' to download
- updates to this sample. Notice how we never asked you for your Twitter username
- or password. </p>
+ <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>
diff --git a/samples/OAuthConsumer/Twitter.aspx.cs b/samples/OAuthConsumer/Twitter.aspx.cs
index 9b9eced..f309396 100644
--- a/samples/OAuthConsumer/Twitter.aspx.cs
+++ b/samples/OAuthConsumer/Twitter.aspx.cs
@@ -75,4 +75,20 @@ public partial class Twitter : System.Web.UI.Page {
tableBuilder.Append("</table>");
resultsPlaceholder.Controls.Add(new Literal { Text = tableBuilder.ToString() });
}
+
+ protected void uploadProfilePhotoButton_Click(object sender, EventArgs e) {
+ if (profilePhoto.PostedFile.ContentType == null) {
+ photoUploadedLabel.Visible = true;
+ photoUploadedLabel.Text = "Select a file first.";
+ return;
+ }
+
+ var twitter = new WebConsumer(TwitterConsumer.ServiceDescription, this.TokenManager);
+ XDocument imageResult = TwitterConsumer.UpdateProfileImage(
+ twitter,
+ this.AccessToken,
+ profilePhoto.PostedFile.InputStream,
+ profilePhoto.PostedFile.ContentType);
+ photoUploadedLabel.Visible = true;
+ }
}
diff --git a/samples/OAuthConsumer/Web.config b/samples/OAuthConsumer/Web.config
index c3a808a..496da95 100644
--- a/samples/OAuthConsumer/Web.config
+++ b/samples/OAuthConsumer/Web.config
@@ -3,6 +3,7 @@
<configSections>
<section name="uri" type="System.Configuration.UriSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" requirePermission="false" />
+ <section name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection" requirePermission="false" allowLocation="true"/>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
@@ -34,6 +35,12 @@
</settings>
</system.net>
+ <!-- this is an optional configuration section where aspects of dotnetopenauth can be customized -->
+ <dotNetOpenAuth>
+ <!-- Allow DotNetOpenAuth to publish usage statistics to library authors to improve the library. -->
+ <reporting enabled="true" />
+ </dotNetOpenAuth>
+
<appSettings>
<!-- Fill in your various consumer keys and secrets here to make the sample work. -->
<!-- You must get these values by signing up with each individual service provider. -->
@@ -59,6 +66,7 @@
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
+ <remove assembly="DotNetOpenAuth.Contracts"/>
</assemblies>
</compilation>
<!--