btcpayserver/BTCPayServer.Client/BTCPayServerClient.Authorization.cs

35 lines
1.2 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
2020-11-13 06:01:51 +01:00
using System.Threading.Tasks;
namespace BTCPayServer.Client
{
public partial class BTCPayServerClient
{
2020-06-28 10:55:27 +02:00
public static Uri GenerateAuthorizeUri(Uri btcpayHost, string[] permissions, bool strict = true,
2020-08-04 13:10:48 +02:00
bool selectiveStores = false, (string ApplicationIdentifier, Uri Redirect) applicationDetails = default)
{
var result = new UriBuilder(btcpayHost);
result.Path = "api-keys/authorize";
AppendPayloadToQuery(result,
new Dictionary<string, object>()
{
{"strict", strict}, {"selectiveStores", selectiveStores}, {"permissions", permissions}
});
2020-08-04 13:10:48 +02:00
if (applicationDetails.Redirect != null)
{
AppendPayloadToQuery(result, new KeyValuePair<string, object>("redirect", applicationDetails.Redirect));
if (!string.IsNullOrEmpty(applicationDetails.ApplicationIdentifier))
{
AppendPayloadToQuery(result, new KeyValuePair<string, object>("applicationIdentifier", applicationDetails.ApplicationIdentifier));
}
}
return result.Uri;
}
}
}