summaryrefslogtreecommitdiffstats
path: root/samples/OAuthClient/WindowsLive.aspx.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2013-05-27 09:32:17 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2013-05-27 09:32:17 -0700
commit5a0a8ee4c55f323a6c1fbdb619cd89b7d28a94ba (patch)
tree026bb7a58fc6b80b680f2b5be2a25ddf1efbf0f5 /samples/OAuthClient/WindowsLive.aspx.cs
parente4c746826690259eddba106e8a44d1b52b542faf (diff)
parent064220dbab72b00f23abd041bf4a30ea87a00d88 (diff)
downloadDotNetOpenAuth-5a0a8ee4c55f323a6c1fbdb619cd89b7d28a94ba.zip
DotNetOpenAuth-5a0a8ee4c55f323a6c1fbdb619cd89b7d28a94ba.tar.gz
DotNetOpenAuth-5a0a8ee4c55f323a6c1fbdb619cd89b7d28a94ba.tar.bz2
Merge branch 'v4.3'
Conflicts: samples/OAuthClient/Default.aspx samples/OAuthClient/Facebook.aspx.cs samples/OAuthClient/Web.config samples/OAuthClient/WindowsLive.aspx.cs samples/OAuthClient/packages.config src/DotNetOpenAuth.Core/Messaging/OutgoingWebResponse.cs src/DotNetOpenAuth.Core/Messaging/StandardWebRequestHandler.cs src/DotNetOpenAuth.OAuth.Consumer/OAuth/ConsumerBase.cs src/DotNetOpenAuth.OAuth.Consumer/OAuth/OAuth1HmacSha1HttpMessageHandler.cs src/DotNetOpenAuth.OAuth.Consumer/OAuth/OAuth1HttpMessageHandlerBase.cs src/DotNetOpenAuth.OAuth.Consumer/OAuth/OAuth1PlainTextMessageHandler.cs src/DotNetOpenAuth.OAuth.Consumer/OAuth/OAuth1RsaSha1HttpMessageHandler.cs src/DotNetOpenAuth.OAuth2.Client/OAuth2/WebServerClient.cs src/packages/repositories.config src/version.txt
Diffstat (limited to 'samples/OAuthClient/WindowsLive.aspx.cs')
-rw-r--r--samples/OAuthClient/WindowsLive.aspx.cs34
1 files changed, 17 insertions, 17 deletions
diff --git a/samples/OAuthClient/WindowsLive.aspx.cs b/samples/OAuthClient/WindowsLive.aspx.cs
index a3725e9..61dc443 100644
--- a/samples/OAuthClient/WindowsLive.aspx.cs
+++ b/samples/OAuthClient/WindowsLive.aspx.cs
@@ -1,4 +1,5 @@
-namespace OAuthClient {
+namespace OAuthClient
+{
using System;
using System.Collections.Generic;
using System.Configuration;
@@ -8,12 +9,13 @@
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetOpenAuth.ApplicationBlock;
- using DotNetOpenAuth.ApplicationBlock.Facebook;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OAuth2;
- public partial class WindowsLive : System.Web.UI.Page {
- private static readonly WindowsLiveClient client = new WindowsLiveClient {
+ public partial class WindowsLive : System.Web.UI.Page
+ {
+ private static readonly WindowsLiveClient windowsLiveClient = new WindowsLiveClient
+ {
ClientIdentifier = ConfigurationManager.AppSettings["windowsLiveAppID"],
ClientCredentialApplicator = ClientCredentialApplicator.PostParameter(ConfigurationManager.AppSettings["WindowsLiveAppSecret"]),
};
@@ -29,23 +31,21 @@
this.publicLink.NavigateUrl = builder.Uri.AbsoluteUri;
this.publicLink.Text = builder.Uri.AbsoluteUri;
} else {
- IAuthorizationState authorization =
- await client.ProcessUserAuthorizationAsync(new HttpRequestWrapper(Request), Response.ClientDisconnectedToken);
+ IAuthorizationState authorization = await windowsLiveClient.ProcessUserAuthorizationAsync(new HttpRequestWrapper(Request), ct);
if (authorization == null) {
// Kick off authorization request
- var request = await client.PrepareRequestUserAuthorizationAsync(scopes: new[] { WindowsLiveClient.Scopes.Basic }); // this scope isn't even required just to log in
- await request.SendAsync(new HttpContextWrapper(this.Context), Response.ClientDisconnectedToken);
+ var request = await windowsLiveClient.PrepareRequestUserAuthorizationAsync(
+ scopes: new[] { WindowsLiveClient.Scopes.Basic }, // this scope isn't even required just to log in
+ cancellationToken: ct);
+ await request.SendAsync(new HttpContextWrapper(Context), ct);
this.Context.Response.End();
+
+ // alternatively you can ask for more information
+ // windowsLiveClient.RequestUserAuthorization(scope: new[] { WindowsLiveClient.Scopes.SignIn, WindowsLiveClient.Scopes.Emails, WindowsLiveClient.Scopes.Birthday });
} else {
- var request =
- WebRequest.Create(
- "https://apis.live.net/v5.0/me?access_token=" + Uri.EscapeDataString(authorization.AccessToken));
- using (var response = request.GetResponse()) {
- using (var responseStream = response.GetResponseStream()) {
- var graph = WindowsLiveGraph.Deserialize(responseStream);
- this.nameLabel.Text = HttpUtility.HtmlEncode(graph.Name);
- }
- }
+ IOAuth2Graph oauth2Graph = windowsLiveClient.GetGraph(authorization);
+
+ this.nameLabel.Text = HttpUtility.HtmlEncode(oauth2Graph.Name);
}
}
}));