diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-02 09:25:24 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-02 09:25:24 -0800 |
commit | cd7bed180abfe36ba4ae778d70cd7976de55907d (patch) | |
tree | 27c94ba5cede9387c2abafff97c817ab575313ad | |
parent | 1a1a37ebb26034d2f5470c3be2da18cefe5293da (diff) | |
download | DotNetOpenAuth-cd7bed180abfe36ba4ae778d70cd7976de55907d.zip DotNetOpenAuth-cd7bed180abfe36ba4ae778d70cd7976de55907d.tar.gz DotNetOpenAuth-cd7bed180abfe36ba4ae778d70cd7976de55907d.tar.bz2 |
Fixes some recent regressions to get twitter.aspx working.
4 files changed, 15 insertions, 4 deletions
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs b/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs index bb6f9d3..96e59ad 100644 --- a/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs +++ b/samples/DotNetOpenAuth.ApplicationBlock/TwitterConsumer.cs @@ -159,6 +159,10 @@ namespace DotNetOpenAuth.ApplicationBlock { } public async Task<JArray> GetUpdatesAsync(AccessToken accessToken, CancellationToken cancellationToken = default(CancellationToken)) { + if (String.IsNullOrEmpty(accessToken.Token)) { + throw new ArgumentNullException("accessToken.Token"); + } + using (var httpClient = this.CreateHttpClient(accessToken)) { using (var response = await httpClient.GetAsync(GetFriendTimelineStatusEndpoint, cancellationToken)) { response.EnsureSuccessStatusCode(); @@ -170,6 +174,10 @@ namespace DotNetOpenAuth.ApplicationBlock { } public async Task<XDocument> GetFavorites(AccessToken accessToken, CancellationToken cancellationToken = default(CancellationToken)) { + if (String.IsNullOrEmpty(accessToken.Token)) { + throw new ArgumentNullException("accessToken.Token"); + } + using (var httpClient = this.CreateHttpClient(accessToken)) { using (HttpResponseMessage response = await httpClient.GetAsync(GetFavoritesEndpoint, cancellationToken)) { response.EnsureSuccessStatusCode(); diff --git a/samples/OAuthConsumer/Twitter.aspx.cs b/samples/OAuthConsumer/Twitter.aspx.cs index e107928..f9df3b2 100644 --- a/samples/OAuthConsumer/Twitter.aspx.cs +++ b/samples/OAuthConsumer/Twitter.aspx.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Configuration; using System.Linq; + using System.Net; using System.Text; using System.Web; using System.Web.UI; @@ -15,7 +16,7 @@ public partial class Twitter : System.Web.UI.Page { private AccessToken AccessToken { - get { return (AccessToken)Session["TwitterAccessToken"]; } + get { return (AccessToken)(Session["TwitterAccessToken"] ?? new AccessToken()); } set { Session["TwitterAccessToken"] = value; } } @@ -33,6 +34,7 @@ // If we don't yet have access, immediately request it. Uri redirectUrl = await twitter.RequestUserAuthorizationAsync(MessagingUtilities.GetPublicFacingUrl()); this.Response.RedirectLocation = redirectUrl.AbsoluteUri; + this.Response.StatusCode = (int)HttpStatusCode.Redirect; } } } diff --git a/src/DotNetOpenAuth.OAuth.Consumer/OAuth/Consumer.cs b/src/DotNetOpenAuth.OAuth.Consumer/OAuth/Consumer.cs index 578902c..560e536 100644 --- a/src/DotNetOpenAuth.OAuth.Consumer/OAuth/Consumer.cs +++ b/src/DotNetOpenAuth.OAuth.Consumer/OAuth/Consumer.cs @@ -215,7 +215,7 @@ namespace DotNetOpenAuth.OAuth { /// <returns> /// The access token assigned by the Service Provider, or <c>null</c> if no response was detected in the specified URL. /// </returns> - public Task<AccessTokenResponse> ProcessUserAuthorizationAsync(Uri authorizationCompleteUri, CancellationToken cancellationToken = default(CancellationToken)) { + public async Task<AccessTokenResponse> ProcessUserAuthorizationAsync(Uri authorizationCompleteUri, CancellationToken cancellationToken = default(CancellationToken)) { Requires.NotNull(authorizationCompleteUri, "authorizationCompleteUri"); Verify.Operation(this.TemporaryCredentialStorage != null, Strings.RequiredPropertyNotYetPreset, "TemporaryCredentialStorage"); @@ -235,7 +235,7 @@ namespace DotNetOpenAuth.OAuth { var temporaryCredential = this.TemporaryCredentialStorage.RetrieveTemporaryCredential(); Verify.Operation(string.Equals(temporaryCredential.Key, identifier, StringComparison.Ordinal), "Temporary credential identifiers do not match."); - return this.ProcessUserAuthorizationAsync(verifier, cancellationToken); + return await this.ProcessUserAuthorizationAsync(verifier, cancellationToken); } /// <summary> diff --git a/src/DotNetOpenAuth.OAuth.Consumer/OAuth/ServiceProviderDescription.cs b/src/DotNetOpenAuth.OAuth.Consumer/OAuth/ServiceProviderDescription.cs index e6a2b32..2d07af4 100644 --- a/src/DotNetOpenAuth.OAuth.Consumer/OAuth/ServiceProviderDescription.cs +++ b/src/DotNetOpenAuth.OAuth.Consumer/OAuth/ServiceProviderDescription.cs @@ -32,7 +32,8 @@ namespace DotNetOpenAuth.OAuth { /// <param name="resourceOwnerAuthorizationEndpoint">The resource owner authorization endpoint.</param> /// <param name="tokenRequestEndpoint">The token request endpoint.</param> public ServiceProviderDescription( - string temporaryCredentialsRequestEndpoint, string resourceOwnerAuthorizationEndpoint, string tokenRequestEndpoint) { + string temporaryCredentialsRequestEndpoint, string resourceOwnerAuthorizationEndpoint, string tokenRequestEndpoint) + : this() { if (temporaryCredentialsRequestEndpoint != null) { this.TemporaryCredentialsRequestEndpoint = new Uri(temporaryCredentialsRequestEndpoint, UriKind.Absolute); } |