summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatt Johnson <mj1856@hotmail.com>2013-02-28 17:30:52 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2013-05-26 10:23:59 -0700
commit033d0217988e26ae77d3378aec82905cebad0f86 (patch)
treee29004e5ed91bf2e99058c3581424c6210affa0a /src
parent9c77f36b54bdde6f10bb8b6808f916a27d97772b (diff)
downloadDotNetOpenAuth-033d0217988e26ae77d3378aec82905cebad0f86.zip
DotNetOpenAuth-033d0217988e26ae77d3378aec82905cebad0f86.tar.gz
DotNetOpenAuth-033d0217988e26ae77d3378aec82905cebad0f86.tar.bz2
Improve Microsoft Client
Allow the developer to specify different scopes. Set the default scope to "wl.signin" instead of "wl.basic". This provides a better out-of-the-box experience. See http://stackoverflow.com/q/15125410/634824
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth.AspNet/Clients/OAuth2/MicrosoftClient.cs33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/DotNetOpenAuth.AspNet/Clients/OAuth2/MicrosoftClient.cs b/src/DotNetOpenAuth.AspNet/Clients/OAuth2/MicrosoftClient.cs
index 653a0b0..d50f3c5 100644
--- a/src/DotNetOpenAuth.AspNet/Clients/OAuth2/MicrosoftClient.cs
+++ b/src/DotNetOpenAuth.AspNet/Clients/OAuth2/MicrosoftClient.cs
@@ -37,21 +37,34 @@ namespace DotNetOpenAuth.AspNet.Clients {
/// </summary>
private readonly string appSecret;
+ /// <summary>
+ /// The requested scopes.
+ /// </summary>
+ private readonly string[] requestedScopes;
+
#endregion
#region Constructors and Destructors
/// <summary>
/// Initializes a new instance of the <see cref="MicrosoftClient"/> class.
+ /// Requests a scope of "wl.signin" by default.
/// </summary>
- /// <param name="appId">
- /// The app id.
- /// </param>
- /// <param name="appSecret">
- /// The app secret.
- /// </param>
+ /// <param name="appId">The app id.</param>
+ /// <param name="appSecret">The app secret.</param>
public MicrosoftClient(string appId, string appSecret)
- : this("microsoft", appId, appSecret) {
+ : this("microsoft", appId, appSecret, "wl.signin")
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MicrosoftClient"/> class.
+ /// </summary>
+ /// <param name="appId">The app id.</param>
+ /// <param name="appSecret">The app secret.</param>
+ /// <param name="requestedScopes">One or more requested scopes.</param>
+ public MicrosoftClient(string appId, string appSecret, params string[] requestedScopes)
+ : this("microsoft", appId, appSecret, requestedScopes) {
}
/// <summary>
@@ -60,13 +73,15 @@ namespace DotNetOpenAuth.AspNet.Clients {
/// <param name="providerName">The provider name.</param>
/// <param name="appId">The app id.</param>
/// <param name="appSecret">The app secret.</param>
- protected MicrosoftClient(string providerName, string appId, string appSecret)
+ /// <param name="requestedScopes">One or more requested scopes.</param>
+ protected MicrosoftClient(string providerName, string appId, string appSecret, string[] requestedScopes)
: base(providerName) {
Requires.NotNullOrEmpty(appId, "appId");
Requires.NotNullOrEmpty(appSecret, "appSecret");
this.appId = appId;
this.appSecret = appSecret;
+ this.requestedScopes = requestedScopes;
}
#endregion
@@ -92,7 +107,7 @@ namespace DotNetOpenAuth.AspNet.Clients {
builder.AppendQueryArgs(
new Dictionary<string, string> {
{ "client_id", this.appId },
- { "scope", "wl.basic" },
+ { "scope", string.Join(" ", this.requestedScopes) },
{ "response_type", "code" },
{ "redirect_uri", returnUrl.AbsoluteUri },
});