summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth/DesktopConsumer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOAuth/DesktopConsumer.cs')
-rw-r--r--src/DotNetOAuth/DesktopConsumer.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/DotNetOAuth/DesktopConsumer.cs b/src/DotNetOAuth/DesktopConsumer.cs
new file mode 100644
index 0000000..99f3765
--- /dev/null
+++ b/src/DotNetOAuth/DesktopConsumer.cs
@@ -0,0 +1,54 @@
+//-----------------------------------------------------------------------
+// <copyright file="DesktopConsumer.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth {
+ using System;
+ using System.Collections.Generic;
+ using System.Net;
+ using System.Web;
+ using DotNetOAuth.ChannelElements;
+ using DotNetOAuth.Messages;
+ using DotNetOAuth.Messaging;
+ using DotNetOAuth.Messaging.Bindings;
+
+ /// <summary>
+ /// Used by a desktop application to use OAuth to access the Service Provider on behalf of the User.
+ /// </summary>
+ /// <remarks>
+ /// The methods on this class are thread-safe. Provided the properties are set and not changed
+ /// afterward, a single instance of this class may be used by an entire web application safely.
+ /// </remarks>
+ public class DesktopConsumer : ConsumerBase {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DesktopConsumer"/> class.
+ /// </summary>
+ /// <param name="serviceDescription">The endpoints and behavior of the Service Provider.</param>
+ /// <param name="tokenManager">The host's method of storing and recalling tokens and secrets.</param>
+ public DesktopConsumer(ServiceProviderDescription serviceDescription, ITokenManager tokenManager)
+ : base(serviceDescription, tokenManager) {
+ }
+
+ /// <summary>
+ /// Begins an OAuth authorization request.
+ /// </summary>
+ /// <param name="requestParameters">Extra parameters to add to the request token message. Optional.</param>
+ /// <param name="redirectParameters">Extra parameters to add to the redirect to Service Provider message. Optional.</param>
+ /// <param name="requestToken">The request token that must be exchanged for an access token after the user has provided authorization.</param>
+ /// <returns>The URL to open a browser window to allow the user to provide authorization.</returns>
+ public Uri RequestUserAuthorization(IDictionary<string, string> requestParameters, IDictionary<string, string> redirectParameters, out string requestToken) {
+ return this.RequestUserAuthorization(null, requestParameters, redirectParameters, out requestToken).DirectUriRequest;
+ }
+
+ /// <summary>
+ /// Exchanges a given request token for access token.
+ /// </summary>
+ /// <param name="requestToken">The request token that the user has authorized.</param>
+ /// <returns>The access token assigned by the Service Provider.</returns>
+ public new GrantAccessTokenMessage ProcessUserAuthorization(string requestToken) {
+ return base.ProcessUserAuthorization(requestToken);
+ }
+ }
+}