diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-02-19 16:21:25 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-02-19 16:21:25 -0800 |
commit | 6d037a420c0d304bb2edeee17dce1b11db60b2bf (patch) | |
tree | 1a771e79f7fd4f04d4522e7fc6f8045d87a88572 | |
parent | 32270c7413e7a2c37a02341a0894e2447f6d74f7 (diff) | |
download | DotNetOpenAuth-6d037a420c0d304bb2edeee17dce1b11db60b2bf.zip DotNetOpenAuth-6d037a420c0d304bb2edeee17dce1b11db60b2bf.tar.gz DotNetOpenAuth-6d037a420c0d304bb2edeee17dce1b11db60b2bf.tar.bz2 |
Removes OAuth 1 samples from the OAuth 2 site.
-rw-r--r-- | samples/OAuthClient/GoogleAddressBook.aspx | 26 | ||||
-rw-r--r-- | samples/OAuthClient/GoogleAddressBook.aspx.cs | 75 | ||||
-rw-r--r-- | samples/OAuthClient/GoogleAddressBook.aspx.designer.cs | 42 | ||||
-rw-r--r-- | samples/OAuthClient/GoogleApps2Legged.aspx | 25 | ||||
-rw-r--r-- | samples/OAuthClient/GoogleApps2Legged.aspx.cs | 42 | ||||
-rw-r--r-- | samples/OAuthClient/GoogleApps2Legged.aspx.designer.cs | 42 | ||||
-rw-r--r-- | samples/OAuthClient/OAuthClient.csproj | 32 | ||||
-rw-r--r-- | samples/OAuthClient/SignInWithTwitter.aspx | 38 | ||||
-rw-r--r-- | samples/OAuthClient/SignInWithTwitter.aspx.cs | 42 | ||||
-rw-r--r-- | samples/OAuthClient/SignInWithTwitter.aspx.designer.cs | 87 | ||||
-rw-r--r-- | samples/OAuthClient/Yammer.aspx | 48 | ||||
-rw-r--r-- | samples/OAuthClient/Yammer.aspx.cs | 76 | ||||
-rw-r--r-- | samples/OAuthClient/Yammer.aspx.designer.cs | 123 |
13 files changed, 0 insertions, 698 deletions
diff --git a/samples/OAuthClient/GoogleAddressBook.aspx b/samples/OAuthClient/GoogleAddressBook.aspx deleted file mode 100644 index 35e8b0a..0000000 --- a/samples/OAuthClient/GoogleAddressBook.aspx +++ /dev/null @@ -1,26 +0,0 @@ -<%@ Page Title="Gmail address book demo" Language="C#" MasterPageFile="~/MasterPage.master" Async="true" - AutoEventWireup="true" Inherits="OAuthClient.GoogleAddressBook" Codebehind="GoogleAddressBook.aspx.cs" %> - -<asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="Server"> - <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"> - <asp:View runat="server"> - <h2>Google setup</h2> - <p>A Google client app must be endorsed by a Google user. </p> - <ol> - <li><a target="_blank" href="https://www.google.com/accounts/ManageDomains">Visit Google - 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, Google has authorized us to download your contacts. Click 'Get address book' - to download the first 5 contacts to this sample. Notice how we never asked you - for your Google username or password. </p> - <asp:Button ID="getAddressBookButton" runat="server" OnClick="getAddressBookButton_Click" - Text="Get address book" /> - <asp:PlaceHolder ID="resultsPlaceholder" runat="server" /> - </asp:View> - </asp:MultiView> -</asp:Content> diff --git a/samples/OAuthClient/GoogleAddressBook.aspx.cs b/samples/OAuthClient/GoogleAddressBook.aspx.cs deleted file mode 100644 index 2945591..0000000 --- a/samples/OAuthClient/GoogleAddressBook.aspx.cs +++ /dev/null @@ -1,75 +0,0 @@ -namespace OAuthClient { - using System; - 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 DotNetOpenAuth.ApplicationBlock; - using DotNetOpenAuth.OAuth; - - /// <summary> - /// A page to demonstrate downloading a Gmail address book using OAuth. - /// </summary> - public partial class GoogleAddressBook : System.Web.UI.Page { - private string AccessToken { - get { return (string)Session["GoogleAccessToken"]; } - set { Session["GoogleAccessToken"] = value; } - } - - private InMemoryTokenManager TokenManager { - get { - var tokenManager = (InMemoryTokenManager)Application["GoogleTokenManager"]; - if (tokenManager == null) { - string consumerKey = ConfigurationManager.AppSettings["googleConsumerKey"]; - string consumerSecret = ConfigurationManager.AppSettings["googleConsumerSecret"]; - if (!string.IsNullOrEmpty(consumerKey)) { - tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); - Application["GoogleTokenManager"] = tokenManager; - } - } - - return tokenManager; - } - } - - protected async void Page_Load(object sender, EventArgs e) { - if (this.TokenManager != null) { - this.MultiView1.ActiveViewIndex = 1; - - if (!IsPostBack) { - var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); - - // Is Google calling back with authorization? - var accessTokenResponse = await google.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. - await GoogleConsumer.RequestAuthorizationAsync(google, GoogleConsumer.Applications.Contacts, Response.ClientDisconnectedToken); - } - } - } - } - - protected async void getAddressBookButton_Click(object sender, EventArgs e) { - var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); - - XDocument contactsDocument = await GoogleConsumer.GetContactsAsync(google, this.AccessToken, 5, 1, Response.ClientDisconnectedToken); - var contacts = from entry in contactsDocument.Root.Elements(XName.Get("entry", "http://www.w3.org/2005/Atom")) - select new { Name = entry.Element(XName.Get("title", "http://www.w3.org/2005/Atom")).Value, Email = entry.Element(XName.Get("email", "http://schemas.google.com/g/2005")).Attribute("address").Value }; - StringBuilder tableBuilder = new StringBuilder(); - tableBuilder.Append("<table><tr><td>Name</td><td>Email</td></tr>"); - foreach (var contact in contacts) { - tableBuilder.AppendFormat( - "<tr><td>{0}</td><td>{1}</td></tr>", - HttpUtility.HtmlEncode(contact.Name), - HttpUtility.HtmlEncode(contact.Email)); - } - tableBuilder.Append("</table>"); - this.resultsPlaceholder.Controls.Add(new Literal { Text = tableBuilder.ToString() }); - } - } -}
\ No newline at end of file diff --git a/samples/OAuthClient/GoogleAddressBook.aspx.designer.cs b/samples/OAuthClient/GoogleAddressBook.aspx.designer.cs deleted file mode 100644 index 576072e..0000000 --- a/samples/OAuthClient/GoogleAddressBook.aspx.designer.cs +++ /dev/null @@ -1,42 +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 GoogleAddressBook { - - /// <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> - /// getAddressBookButton 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 getAddressBookButton; - - /// <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; - } -} diff --git a/samples/OAuthClient/GoogleApps2Legged.aspx b/samples/OAuthClient/GoogleApps2Legged.aspx deleted file mode 100644 index 92a26a1..0000000 --- a/samples/OAuthClient/GoogleApps2Legged.aspx +++ /dev/null @@ -1,25 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master" CodeBehind="GoogleApps2Legged.aspx.cs" Inherits="OAuthConsumer.GoogleApps2Legged" Async="true" %> - -<asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="Server"> - <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"> - <asp:View runat="server"> - <h2>Google setup</h2> - <p>A Google client app must be endorsed by a Google user. </p> - <ol> - <li><a target="_blank" href="https://www.google.com/accounts/ManageDomains">Visit Google - 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, Google has authorized us to download your contacts. Click 'Get address book' - to download the first 5 contacts to this sample. Notice how we never asked you - for your Google username or password. </p> - <asp:Button ID="getAddressBookButton" runat="server" OnClick="getAddressBookButton_Click" - Text="Get address book" /> - <asp:PlaceHolder ID="resultsPlaceholder" runat="server" /> - </asp:View> - </asp:MultiView> -</asp:Content> diff --git a/samples/OAuthClient/GoogleApps2Legged.aspx.cs b/samples/OAuthClient/GoogleApps2Legged.aspx.cs deleted file mode 100644 index fb39d40..0000000 --- a/samples/OAuthClient/GoogleApps2Legged.aspx.cs +++ /dev/null @@ -1,42 +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; - using DotNetOpenAuth.OAuth.Messages; - - public partial class GoogleApps2Legged : System.Web.UI.Page { - private InMemoryTokenManager TokenManager { - get { - var tokenManager = (InMemoryTokenManager)Application["GoogleTokenManager"]; - if (tokenManager == null) { - string consumerKey = ConfigurationManager.AppSettings["googleConsumerKey"]; - string consumerSecret = ConfigurationManager.AppSettings["googleConsumerSecret"]; - if (!string.IsNullOrEmpty(consumerKey)) { - tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret); - Application["GoogleTokenManager"] = tokenManager; - } - } - - return tokenManager; - } - } - - protected async void Page_Load(object sender, EventArgs e) { - var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager); - string accessToken = await google.RequestNewClientAccountAsync(cancellationToken: Response.ClientDisconnectedToken); - ////string tokenSecret = google.TokenManager.GetTokenSecret(accessToken); - MessageReceivingEndpoint ep = null; // set up your authorized call here. - var request = await google.PrepareAuthorizedRequestAsync(ep, accessToken, Response.ClientDisconnectedToken); - using (var httpClient = google.Channel.HostFactories.CreateHttpClient()) { - await httpClient.SendAsync(request, Response.ClientDisconnectedToken); - } - } - } -}
\ No newline at end of file diff --git a/samples/OAuthClient/GoogleApps2Legged.aspx.designer.cs b/samples/OAuthClient/GoogleApps2Legged.aspx.designer.cs deleted file mode 100644 index f952937..0000000 --- a/samples/OAuthClient/GoogleApps2Legged.aspx.designer.cs +++ /dev/null @@ -1,42 +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 OAuthConsumer { - - - public partial class GoogleApps2Legged { - - /// <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> - /// getAddressBookButton 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 getAddressBookButton; - - /// <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; - } -} diff --git a/samples/OAuthClient/OAuthClient.csproj b/samples/OAuthClient/OAuthClient.csproj index 61b3a79..eb216b1 100644 --- a/samples/OAuthClient/OAuthClient.csproj +++ b/samples/OAuthClient/OAuthClient.csproj @@ -77,15 +77,12 @@ <Content Include="Facebook.aspx" /> <Content Include="favicon.ico" /> <Content Include="Global.asax" /> - <Content Include="GoogleAddressBook.aspx" /> - <Content Include="GoogleApps2Legged.aspx" /> <Content Include="images\Sign-in-with-Twitter-darker.png" /> <Content Include="SampleWcf2Javascript.html" /> <Content Include="SampleWcf2Javascript.js" /> <Content Include="Scripts\jquery-1.6.1.js" /> <Content Include="Scripts\jquery-1.6.1.min.js" /> <Content Include="WindowsLive.aspx" /> - <Content Include="Yammer.aspx" /> <Content Include="packages.config" /> <None Include="Service References\SampleResourceServer\DataApi.disco" /> <None Include="Service References\SampleResourceServer\configuration91.svcinfo" /> @@ -95,7 +92,6 @@ <LastGenOutput>Reference.cs</LastGenOutput> </None> <Content Include="SampleWcf2.aspx" /> - <Content Include="SignInWithTwitter.aspx" /> <Content Include="TracePage.aspx" /> <Content Include="Web.config" /> <None Include="Service References\SampleResourceServer\DataApi1.xsd"> @@ -119,20 +115,10 @@ <Compile Include="Global.asax.cs"> <DependentUpon>Global.asax</DependentUpon> </Compile> - <Compile Include="GoogleAddressBook.aspx.designer.cs"> - <DependentUpon>GoogleAddressBook.aspx</DependentUpon> - </Compile> <Compile Include="SampleWcf2.aspx.cs"> <DependentUpon>SampleWcf2.aspx</DependentUpon> <SubType>ASPXCodeBehind</SubType> </Compile> - <Compile Include="GoogleApps2Legged.aspx.cs"> - <DependentUpon>GoogleApps2Legged.aspx</DependentUpon> - <SubType>ASPXCodeBehind</SubType> - </Compile> - <Compile Include="GoogleApps2Legged.aspx.designer.cs"> - <DependentUpon>GoogleApps2Legged.aspx</DependentUpon> - </Compile> <Compile Include="SampleWcf2.aspx.designer.cs"> <DependentUpon>SampleWcf2.aspx</DependentUpon> </Compile> @@ -141,13 +127,6 @@ <DesignTime>True</DesignTime> <DependentUpon>Reference.svcmap</DependentUpon> </Compile> - <Compile Include="SignInWithTwitter.aspx.cs"> - <DependentUpon>SignInWithTwitter.aspx</DependentUpon> - <SubType>ASPXCodeBehind</SubType> - </Compile> - <Compile Include="SignInWithTwitter.aspx.designer.cs"> - <DependentUpon>SignInWithTwitter.aspx</DependentUpon> - </Compile> <Compile Include="TracePage.aspx.cs"> <DependentUpon>TracePage.aspx</DependentUpon> <SubType>ASPXCodeBehind</SubType> @@ -157,10 +136,6 @@ </Compile> <Compile Include="Code\Logging.cs" /> <Compile Include="Code\TracePageAppender.cs" /> - <Compile Include="GoogleAddressBook.aspx.cs"> - <DependentUpon>GoogleAddressBook.aspx</DependentUpon> - <SubType>ASPXCodeBehind</SubType> - </Compile> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="WindowsLive.aspx.cs"> <DependentUpon>WindowsLive.aspx</DependentUpon> @@ -169,13 +144,6 @@ <Compile Include="WindowsLive.aspx.designer.cs"> <DependentUpon>WindowsLive.aspx</DependentUpon> </Compile> - <Compile Include="Yammer.aspx.cs"> - <DependentUpon>Yammer.aspx</DependentUpon> - <SubType>ASPXCodeBehind</SubType> - </Compile> - <Compile Include="Yammer.aspx.designer.cs"> - <DependentUpon>Yammer.aspx</DependentUpon> - </Compile> </ItemGroup> <ItemGroup> <Folder Include="App_Data\" /> diff --git a/samples/OAuthClient/SignInWithTwitter.aspx b/samples/OAuthClient/SignInWithTwitter.aspx deleted file mode 100644 index a1d7e65..0000000 --- a/samples/OAuthClient/SignInWithTwitter.aspx +++ /dev/null @@ -1,38 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" Async="true" - Inherits="OAuthClient.SignInWithTwitter" Codebehind="SignInWithTwitter.aspx.cs" %> - -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head runat="server"> - <title>Sign-in with Twitter</title> -</head> -<body> - <form id="form1" runat="server"> - <div> - <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 ID="View2" runat="server"> - <asp:ImageButton ImageUrl="~/images/Sign-in-with-Twitter-darker.png" runat="server" - AlternateText="Sign In With Twitter" ID="signInButton" OnClick="signInButton_Click" /> - <asp:CheckBox Text="force re-login" runat="server" ID="forceLoginCheckbox" /> - <br /> - <asp:Panel runat="server" ID="loggedInPanel" Visible="false"> - Now logged in as - <asp:Label Text="[name]" runat="server" ID="loggedInName" /> - </asp:Panel> - </asp:View> - </asp:MultiView> - </form> -</body> -</html> diff --git a/samples/OAuthClient/SignInWithTwitter.aspx.cs b/samples/OAuthClient/SignInWithTwitter.aspx.cs deleted file mode 100644 index dfc3f7a..0000000 --- a/samples/OAuthClient/SignInWithTwitter.aspx.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace OAuthClient { - using System; - using System.Collections.Generic; - using System.Configuration; - using System.Linq; - using System.Web; - using System.Web.Security; - using System.Web.UI; - using System.Web.UI.WebControls; - using System.Xml.Linq; - using System.Xml.XPath; - using DotNetOpenAuth.ApplicationBlock; - using DotNetOpenAuth.Messaging; - using DotNetOpenAuth.OAuth; - - public partial class SignInWithTwitter : System.Web.UI.Page { - protected async void Page_Load(object sender, EventArgs e) { - if (TwitterConsumer.IsTwitterConsumerConfigured) { - this.MultiView1.ActiveViewIndex = 1; - - if (!IsPostBack) { - var tuple = await TwitterConsumer.TryFinishSignInWithTwitterAsync(Response.ClientDisconnectedToken); - if (tuple != null) { - string screenName = tuple.Item1; - int userId = tuple.Item2; - this.loggedInPanel.Visible = true; - this.loggedInName.Text = screenName; - - // In a real app, the Twitter username would likely be used - // to log the user into the application. - ////FormsAuthentication.RedirectFromLoginPage(screenName, false); - } - } - } - } - - protected async void signInButton_Click(object sender, ImageClickEventArgs e) { - var request = await TwitterConsumer.StartSignInWithTwitterAsync(this.forceLoginCheckbox.Checked, Response.ClientDisconnectedToken); - await request.SendAsync(new HttpResponseWrapper(Response), Response.ClientDisconnectedToken); - } - } -}
\ No newline at end of file diff --git a/samples/OAuthClient/SignInWithTwitter.aspx.designer.cs b/samples/OAuthClient/SignInWithTwitter.aspx.designer.cs deleted file mode 100644 index 00126de..0000000 --- a/samples/OAuthClient/SignInWithTwitter.aspx.designer.cs +++ /dev/null @@ -1,87 +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 SignInWithTwitter { - - /// <summary> - /// form1 control. - /// </summary> - /// <remarks> - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// </remarks> - protected global::System.Web.UI.HtmlControls.HtmlForm form1; - - /// <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> - /// View2 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 View2; - - /// <summary> - /// signInButton 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.ImageButton signInButton; - - /// <summary> - /// forceLoginCheckbox 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.CheckBox forceLoginCheckbox; - - /// <summary> - /// loggedInPanel 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.Panel loggedInPanel; - - /// <summary> - /// loggedInName 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 loggedInName; - } -} diff --git a/samples/OAuthClient/Yammer.aspx b/samples/OAuthClient/Yammer.aspx deleted file mode 100644 index 4f13f3e..0000000 --- a/samples/OAuthClient/Yammer.aspx +++ /dev/null @@ -1,48 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master" Async="true" - CodeBehind="Yammer.aspx.cs" Inherits="OAuthClient.Yammer" %> - -<asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="Server"> - <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"> - <asp:View ID="ClientRegistrationRequiredView" runat="server"> - <h2> - Yammer setup</h2> - <p> - A Yammer client app must be registered. - </p> - <ol> - <li><a target="_blank" href="https://www.yammer.com/client_applications/new">Visit Yammer - and register 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 ID="BeginAuthorizationView" runat="server"> - <asp:Label Text="An error occurred in authorization. You may try again." EnableViewState="false" Visible="false" ForeColor="Red" ID="authorizationErrorLabel" runat="server" /> - <asp:Button Text="Obtain authorization now" runat="server" ID="obtainAuthorizationButton" - OnClick="obtainAuthorizationButton_Click" /> - </asp:View> - <asp:View ID="CompleteAuthorizationView" runat="server"> - After you have authorized Yammer to share your information, please enter the code - Yammer gives you here: - <asp:TextBox runat="server" ID="yammerUserCode" EnableViewState="false" /> - <asp:RequiredFieldValidator ErrorMessage="*" ControlToValidate="yammerUserCode" runat="server" /> - <asp:Button Text="Finish" runat="server" ID="finishAuthorizationButton" OnClick="finishAuthorizationButton_Click" /> - </asp:View> - <asp:View ID="AuthorizationCompleteView" runat="server"> - <h2> - Updates - </h2> - <p>The access token we have obtained is: - <asp:Label ID="accessTokenLabel" runat="server" /> - </p> - <p> - Ok, Yammer has authorized us to download your messages. Click 'Get messages' - to download the latest few messages to this sample. Notice how we never asked you - for your Yammer username or password. - </p> - <asp:Button ID="getYammerMessagesButton" runat="server" OnClick="getYammerMessages_Click" - Text="Get address book" /> - <asp:PlaceHolder ID="resultsPlaceholder" runat="server" /> - </asp:View> - </asp:MultiView> -</asp:Content> diff --git a/samples/OAuthClient/Yammer.aspx.cs b/samples/OAuthClient/Yammer.aspx.cs deleted file mode 100644 index f2549a4..0000000 --- a/samples/OAuthClient/Yammer.aspx.cs +++ /dev/null @@ -1,76 +0,0 @@ -namespace OAuthClient { - 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 async void obtainAuthorizationButton_Click(object sender, EventArgs e) { - var yammer = YammerConsumer.CreateConsumer(this.TokenManager); - var tuple = await YammerConsumer.PrepareRequestAuthorizationAsync(yammer, Response.ClientDisconnectedToken); - Uri popupWindowLocation = tuple.Item1; - this.RequestToken = tuple.Item2; - string javascript = "window.open('" + popupWindowLocation.AbsoluteUri + "');"; - this.Page.ClientScript.RegisterStartupScript(GetType(), "YammerPopup", javascript, true); - this.MultiView1.SetActiveView(this.CompleteAuthorizationView); - } - - protected async void finishAuthorizationButton_Click(object sender, EventArgs e) { - if (!Page.IsValid) { - return; - } - - var yammer = YammerConsumer.CreateConsumer(this.TokenManager); - var authorizationResponse = await YammerConsumer.CompleteAuthorizationAsync(yammer, this.RequestToken, this.yammerUserCode.Text, Response.ClientDisconnectedToken); - 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 diff --git a/samples/OAuthClient/Yammer.aspx.designer.cs b/samples/OAuthClient/Yammer.aspx.designer.cs deleted file mode 100644 index 84d75b8..0000000 --- a/samples/OAuthClient/Yammer.aspx.designer.cs +++ /dev/null @@ -1,123 +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 Yammer { - - /// <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> - /// ClientRegistrationRequiredView 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 ClientRegistrationRequiredView; - - /// <summary> - /// BeginAuthorizationView 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 BeginAuthorizationView; - - /// <summary> - /// authorizationErrorLabel 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 authorizationErrorLabel; - - /// <summary> - /// obtainAuthorizationButton 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 obtainAuthorizationButton; - - /// <summary> - /// CompleteAuthorizationView 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 CompleteAuthorizationView; - - /// <summary> - /// yammerUserCode 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.TextBox yammerUserCode; - - /// <summary> - /// finishAuthorizationButton 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 finishAuthorizationButton; - - /// <summary> - /// AuthorizationCompleteView 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 AuthorizationCompleteView; - - /// <summary> - /// accessTokenLabel 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 accessTokenLabel; - - /// <summary> - /// getYammerMessagesButton 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 getYammerMessagesButton; - - /// <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; - } -} |