//-----------------------------------------------------------------------
//
// Copyright (c) Andrew Arnott. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOAuth.OAuth {
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using DotNetOAuth.Messaging;
using DotNetOAuth.OAuth.ChannelElements;
using DotNetOAuth.OAuth.Messages;
///
/// Used by a desktop application to use OAuth to access the Service Provider on behalf of the User.
///
///
/// 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 desktop application safely.
///
public class DesktopConsumer : ConsumerBase {
///
/// Initializes a new instance of the class.
///
/// The endpoints and behavior of the Service Provider.
/// The host's method of storing and recalling tokens and secrets.
public DesktopConsumer(ServiceProviderDescription serviceDescription, ITokenManager tokenManager)
: base(serviceDescription, tokenManager) {
}
///
/// Begins an OAuth authorization request.
///
/// Extra parameters to add to the request token message. Optional.
/// Extra parameters to add to the redirect to Service Provider message. Optional.
/// The request token that must be exchanged for an access token after the user has provided authorization.
/// The URL to open a browser window to allow the user to provide authorization.
[SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Justification = "Two results")]
public Uri RequestUserAuthorization(IDictionary requestParameters, IDictionary redirectParameters, out string requestToken) {
var message = this.PrepareRequestUserAuthorization(null, requestParameters, redirectParameters, out requestToken);
Response response = this.Channel.Send(message);
return response.DirectUriRequest;
}
///
/// Exchanges a given request token for access token.
///
/// The request token that the user has authorized.
/// The access token assigned by the Service Provider.
public new AuthorizedTokenResponse ProcessUserAuthorization(string requestToken) {
return base.ProcessUserAuthorization(requestToken);
}
}
}