summaryrefslogtreecommitdiffstats
path: root/samples/DotNetOpenAuth.ApplicationBlock
diff options
context:
space:
mode:
Diffstat (limited to 'samples/DotNetOpenAuth.ApplicationBlock')
-rw-r--r--samples/DotNetOpenAuth.ApplicationBlock/DotNetOpenAuth.ApplicationBlock.csproj2
-rw-r--r--samples/DotNetOpenAuth.ApplicationBlock/Facebook/FacebookGraph.cs2
-rw-r--r--samples/DotNetOpenAuth.ApplicationBlock/InMemoryTokenManager.cs4
-rw-r--r--samples/DotNetOpenAuth.ApplicationBlock/WindowsLiveClient.cs52
-rw-r--r--samples/DotNetOpenAuth.ApplicationBlock/WindowsLiveGraph.cs60
5 files changed, 117 insertions, 3 deletions
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/DotNetOpenAuth.ApplicationBlock.csproj b/samples/DotNetOpenAuth.ApplicationBlock/DotNetOpenAuth.ApplicationBlock.csproj
index 43b4a00..522a8ab 100644
--- a/samples/DotNetOpenAuth.ApplicationBlock/DotNetOpenAuth.ApplicationBlock.csproj
+++ b/samples/DotNetOpenAuth.ApplicationBlock/DotNetOpenAuth.ApplicationBlock.csproj
@@ -101,6 +101,8 @@
<Compile Include="TokenManager.cs" />
<Compile Include="TwitterConsumer.cs" />
<Compile Include="Util.cs" />
+ <Compile Include="WindowsLiveClient.cs" />
+ <Compile Include="WindowsLiveGraph.cs" />
<Compile Include="YammerConsumer.cs" />
<Compile Include="YubikeyRelyingParty.cs" />
</ItemGroup>
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/Facebook/FacebookGraph.cs b/samples/DotNetOpenAuth.ApplicationBlock/Facebook/FacebookGraph.cs
index 5b1591d..909ae9a 100644
--- a/samples/DotNetOpenAuth.ApplicationBlock/Facebook/FacebookGraph.cs
+++ b/samples/DotNetOpenAuth.ApplicationBlock/Facebook/FacebookGraph.cs
@@ -36,7 +36,7 @@ namespace DotNetOpenAuth.ApplicationBlock.Facebook {
public string Birthday { get; set; }
public static FacebookGraph Deserialize(string json) {
- if (String.IsNullOrEmpty(json)) {
+ if (string.IsNullOrEmpty(json)) {
throw new ArgumentNullException("json");
}
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/InMemoryTokenManager.cs b/samples/DotNetOpenAuth.ApplicationBlock/InMemoryTokenManager.cs
index a4f6154..35f6c08 100644
--- a/samples/DotNetOpenAuth.ApplicationBlock/InMemoryTokenManager.cs
+++ b/samples/DotNetOpenAuth.ApplicationBlock/InMemoryTokenManager.cs
@@ -31,7 +31,7 @@ namespace DotNetOpenAuth.ApplicationBlock {
/// <param name="consumerKey">The consumer key.</param>
/// <param name="consumerSecret">The consumer secret.</param>
public InMemoryTokenManager(string consumerKey, string consumerSecret) {
- if (String.IsNullOrEmpty(consumerKey)) {
+ if (string.IsNullOrEmpty(consumerKey)) {
throw new ArgumentNullException("consumerKey");
}
@@ -136,7 +136,7 @@ namespace DotNetOpenAuth.ApplicationBlock {
/// send a follow-up request for the access token.</para>
/// </remarks>
public void StoreOpenIdAuthorizedRequestToken(string consumerKey, AuthorizationApprovedResponse authorization) {
- this.tokensAndSecrets[authorization.RequestToken] = String.Empty;
+ this.tokensAndSecrets[authorization.RequestToken] = string.Empty;
}
#endregion
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/WindowsLiveClient.cs b/samples/DotNetOpenAuth.ApplicationBlock/WindowsLiveClient.cs
new file mode 100644
index 0000000..be0a650
--- /dev/null
+++ b/samples/DotNetOpenAuth.ApplicationBlock/WindowsLiveClient.cs
@@ -0,0 +1,52 @@
+//-----------------------------------------------------------------------
+// <copyright file="WindowsLiveClient.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.ApplicationBlock {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Text;
+ using DotNetOpenAuth.OAuth2;
+
+ public class WindowsLiveClient : WebServerClient {
+ private static readonly AuthorizationServerDescription WindowsLiveDescription = new AuthorizationServerDescription {
+ TokenEndpoint = new Uri("https://oauth.live.com/token"),
+ AuthorizationEndpoint = new Uri("https://oauth.live.com/authorize"),
+ };
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="WindowsLiveClient"/> class.
+ /// </summary>
+ public WindowsLiveClient()
+ : base(WindowsLiveDescription) {
+ this.AuthorizationTracker = new TokenManager();
+ }
+
+ /// <summary>
+ /// Well-known scopes defined by the Windows Live service.
+ /// </summary>
+ /// <remarks>
+ /// This sample includes just a few scopes. For a complete list of scopes please refer to:
+ /// http://msdn.microsoft.com/en-us/library/hh243646.aspx
+ /// </remarks>
+ public static class Scopes {
+ /// <summary>
+ /// The ability of an app to read and update a user's info at any time. Without this scope, an app can access the user's info only while the user is signed in to Live Connect and is using your app.
+ /// </summary>
+ public const string OfflineAccess = "wl.offline_access";
+
+ /// <summary>
+ /// Single sign-in behavior. With single sign-in, users who are already signed in to Live Connect are also signed in to your website.
+ /// </summary>
+ public const string SignIn = "wl.signin";
+
+ /// <summary>
+ /// Read access to a user's basic profile info. Also enables read access to a user's list of contacts.
+ /// </summary>
+ public const string Basic = "wl.basic";
+ }
+ }
+}
diff --git a/samples/DotNetOpenAuth.ApplicationBlock/WindowsLiveGraph.cs b/samples/DotNetOpenAuth.ApplicationBlock/WindowsLiveGraph.cs
new file mode 100644
index 0000000..4801226
--- /dev/null
+++ b/samples/DotNetOpenAuth.ApplicationBlock/WindowsLiveGraph.cs
@@ -0,0 +1,60 @@
+//-----------------------------------------------------------------------
+// <copyright file="WindowsLiveGraph.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.ApplicationBlock {
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Runtime.Serialization;
+ using System.Runtime.Serialization.Json;
+ using System.Text;
+
+ [DataContract]
+ public class WindowsLiveGraph {
+ private static DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(WindowsLiveGraph));
+
+ [DataMember(Name = "id")]
+ public string Id { get; set; }
+
+ [DataMember(Name = "name")]
+ public string Name { get; set; }
+
+ [DataMember(Name = "first_name")]
+ public string FirstName { get; set; }
+
+ [DataMember(Name = "last_name")]
+ public string LastName { get; set; }
+
+ [DataMember(Name = "link")]
+ public Uri Link { get; set; }
+
+ [DataMember(Name = "gender")]
+ public string Gender { get; set; }
+
+ [DataMember(Name = "updated_time")]
+ public string UpdatedTime { get; set; }
+
+ [DataMember(Name = "locale")]
+ public string Locale { get; set; }
+
+ public static WindowsLiveGraph Deserialize(string json) {
+ if (string.IsNullOrEmpty(json)) {
+ throw new ArgumentNullException("json");
+ }
+
+ return Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(json)));
+ }
+
+ public static WindowsLiveGraph Deserialize(Stream jsonStream) {
+ if (jsonStream == null) {
+ throw new ArgumentNullException("jsonStream");
+ }
+
+ return (WindowsLiveGraph)jsonSerializer.ReadObject(jsonStream);
+ }
+ }
+}