summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2011-06-26 19:55:28 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2011-06-26 19:55:28 -0700
commit1498e4d316838850cbfc40628c70b20b108e340b (patch)
tree1ef7695d44e2ec2e491d6d9370b41dcd03a9dc4b
parent37f71488eba9e010ae7c3a8b4839caeb905dcf58 (diff)
parent9428480e11968a3df460cf7192f43b9d7cfc6ce4 (diff)
downloadDotNetOpenAuth-1498e4d316838850cbfc40628c70b20b108e340b.zip
DotNetOpenAuth-1498e4d316838850cbfc40628c70b20b108e340b.tar.gz
DotNetOpenAuth-1498e4d316838850cbfc40628c70b20b108e340b.tar.bz2
Merge branch 'v3.4'
Conflicts: samples/OAuthClient/OAuthClient.csproj
-rw-r--r--samples/OAuthClient/OAuthClient.csproj7
-rw-r--r--samples/OAuthConsumer/GoogleApps2Legged.aspx25
-rw-r--r--samples/OAuthConsumer/GoogleApps2Legged.aspx.cs39
-rw-r--r--samples/OAuthConsumer/GoogleApps2Legged.aspx.designer.cs42
-rw-r--r--samples/OpenIdRelyingPartyClassicAsp/default.asp6
-rw-r--r--src/DotNetOpenAuth/Messaging/MultipartPostPart.cs4
-rw-r--r--src/DotNetOpenAuth/OAuth/ConsumerBase.cs27
-rw-r--r--tools/DotNetOpenAuth.props1
8 files changed, 149 insertions, 2 deletions
diff --git a/samples/OAuthClient/OAuthClient.csproj b/samples/OAuthClient/OAuthClient.csproj
index 629a3d8..7745c24 100644
--- a/samples/OAuthClient/OAuthClient.csproj
+++ b/samples/OAuthClient/OAuthClient.csproj
@@ -62,6 +62,7 @@
<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" />
@@ -106,8 +107,14 @@
</Compile>
<Compile Include="SampleWcf2.aspx.cs">
<DependentUpon>SampleWcf2.aspx</DependentUpon>
+ </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>
diff --git a/samples/OAuthConsumer/GoogleApps2Legged.aspx b/samples/OAuthConsumer/GoogleApps2Legged.aspx
new file mode 100644
index 0000000..cd9d9a1
--- /dev/null
+++ b/samples/OAuthConsumer/GoogleApps2Legged.aspx
@@ -0,0 +1,25 @@
+<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master"CodeBehind="GoogleApps2Legged.aspx.cs" Inherits="OAuthConsumer.GoogleApps2Legged" %>
+
+<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 &#39;Get address book&#39;
+ 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/OAuthConsumer/GoogleApps2Legged.aspx.cs b/samples/OAuthConsumer/GoogleApps2Legged.aspx.cs
new file mode 100644
index 0000000..afb156b
--- /dev/null
+++ b/samples/OAuthConsumer/GoogleApps2Legged.aspx.cs
@@ -0,0 +1,39 @@
+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 void Page_Load(object sender, EventArgs e) {
+ var google = new WebConsumer(GoogleConsumer.ServiceDescription, this.TokenManager);
+ string accessToken = google.RequestNewClientAccount();
+ ////string tokenSecret = google.TokenManager.GetTokenSecret(accessToken);
+ MessageReceivingEndpoint ep = null; // set up your authorized call here.
+ google.PrepareAuthorizedRequestAndSend(ep, accessToken);
+ }
+ }
+} \ No newline at end of file
diff --git a/samples/OAuthConsumer/GoogleApps2Legged.aspx.designer.cs b/samples/OAuthConsumer/GoogleApps2Legged.aspx.designer.cs
new file mode 100644
index 0000000..f952937
--- /dev/null
+++ b/samples/OAuthConsumer/GoogleApps2Legged.aspx.designer.cs
@@ -0,0 +1,42 @@
+//------------------------------------------------------------------------------
+// <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/OpenIdRelyingPartyClassicAsp/default.asp b/samples/OpenIdRelyingPartyClassicAsp/default.asp
index ddb8dc0..4ab2633 100644
--- a/samples/OpenIdRelyingPartyClassicAsp/default.asp
+++ b/samples/OpenIdRelyingPartyClassicAsp/default.asp
@@ -33,6 +33,12 @@
<span class="command">gacutil.exe /i DotNetOpenAuth.dll</span><br />
Be sure to use a gacutil.exe that comes from a .NET 2.0-3.5 directory (not .NET 1.x).
</li>
+ <li>If your web server is running 64-bit Windows, you&#39;ll also need ensure that the
+ application pool is enabled for 32bit applications. Using IIS Manager, select
+ the appropriate application pool (e.g. &quot;DefaultAppPool&quot; unless you&#39;ve created
+ some new ones). Click &quot;Advanced Settings&quot;, and ensure that &quot;Enable 32bit
+ Applications&quot; is set to True. This setting takes effect immediately, so there&#39;s
+ no need to recycle the application pool.</li>
</ol>
<p>Another thing to be aware of is that with classic ASP there is no Web.config
file in which to customize DotNetOpenAuth behavior.&nbsp; And the COM interfaces
diff --git a/src/DotNetOpenAuth/Messaging/MultipartPostPart.cs b/src/DotNetOpenAuth/Messaging/MultipartPostPart.cs
index 029cd48..eff40dd 100644
--- a/src/DotNetOpenAuth/Messaging/MultipartPostPart.cs
+++ b/src/DotNetOpenAuth/Messaging/MultipartPostPart.cs
@@ -40,10 +40,10 @@ namespace DotNetOpenAuth.Messaging {
}
/// <summary>
- /// Gets the content disposition.
+ /// Gets or sets the content disposition.
/// </summary>
/// <value>The content disposition.</value>
- public string ContentDisposition { get; private set; }
+ public string ContentDisposition { get; set; }
/// <summary>
/// Gets the key=value attributes that appear on the same line as the Content-Disposition.
diff --git a/src/DotNetOpenAuth/OAuth/ConsumerBase.cs b/src/DotNetOpenAuth/OAuth/ConsumerBase.cs
index 2af6988..d9fa889 100644
--- a/src/DotNetOpenAuth/OAuth/ConsumerBase.cs
+++ b/src/DotNetOpenAuth/OAuth/ConsumerBase.cs
@@ -76,6 +76,33 @@ namespace DotNetOpenAuth.OAuth {
internal OAuthChannel OAuthChannel { get; set; }
/// <summary>
+ /// Obtains an access token for a new account at the Service Provider via 2-legged OAuth.
+ /// </summary>
+ /// <param name="requestParameters">Any applicable parameters to include in the query string of the token request.</param>
+ /// <returns>The access token.</returns>
+ /// <remarks>
+ /// The token secret is stored in the <see cref="TokenManager"/>.
+ /// </remarks>
+ public string RequestNewClientAccount(IDictionary<string, string> requestParameters = null) {
+ // Obtain an unauthorized request token. Assume the OAuth version given in the service description.
+ var token = new UnauthorizedTokenRequest(this.ServiceProvider.RequestTokenEndpoint, this.ServiceProvider.Version) {
+ ConsumerKey = this.ConsumerKey,
+ };
+ var tokenAccessor = this.Channel.MessageDescriptions.GetAccessor(token);
+ tokenAccessor.AddExtraParameters(requestParameters);
+ var requestTokenResponse = this.Channel.Request<UnauthorizedTokenResponse>(token);
+ this.TokenManager.StoreNewRequestToken(token, requestTokenResponse);
+
+ var requestAccess = new AuthorizedTokenRequest(this.ServiceProvider.AccessTokenEndpoint, this.ServiceProvider.Version) {
+ RequestToken = requestTokenResponse.RequestToken,
+ ConsumerKey = this.ConsumerKey,
+ };
+ var grantAccess = this.Channel.Request<AuthorizedTokenResponse>(requestAccess);
+ this.TokenManager.ExpireRequestTokenAndStoreNewAccessToken(this.ConsumerKey, requestTokenResponse.RequestToken, grantAccess.AccessToken, grantAccess.TokenSecret);
+ return grantAccess.AccessToken;
+ }
+
+ /// <summary>
/// Creates a web request prepared with OAuth authorization
/// that may be further tailored by adding parameters by the caller.
/// </summary>
diff --git a/tools/DotNetOpenAuth.props b/tools/DotNetOpenAuth.props
index 85ae5b7..8364393 100644
--- a/tools/DotNetOpenAuth.props
+++ b/tools/DotNetOpenAuth.props
@@ -4,6 +4,7 @@
<ProductName>DotNetOpenAuth</ProductName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' ">v3.5</TargetFrameworkVersion>
+ <DisableFastUpToDateCheck>false</DisableFastUpToDateCheck>
<DropsRoot>$(ProjectRoot)drops\$(TargetFrameworkVersion)\$(Configuration)\</DropsRoot>
<OutputPath>$(ProjectRoot)bin\$(TargetFrameworkVersion)\$(Configuration)\</OutputPath>
<DocOutputPath>$(ProjectRoot)doc\</DocOutputPath>