Files
StockSharp/Configuration/ICurrentClientFetcher.cs
mika@stocksharp.com a76333f52a Add ICurrentClientFetcher next to ICredentialsProvider
Configuration already owns the StockSharp-account credentials abstraction:
ICredentialsProvider loads, saves and deletes them. What it did not have is the
third operation - who is signed in right now, and with what token - which is the
one question the credentials dialog asks the web API.

Stating it here rather than in the UI library keeps the dependency pointing the
right way. The dialog does not need to know the shape of the web API; the caller,
which already knows it, supplies the implementation. And a consumer that wants to
answer that question without a WPF reference now can.

Not in Ecng, which was the other candidate: Ecng.Net's IOAuthProvider and
IOAuthToken are generic OAuth - a token by social id, with a value and an expiry.
This is not that. It answers with an email and an access token for OUR account,
and its salt is our own login handshake, not an OAuth notion. Ecng is shared by
projects that have no StockSharp account to ask about.
2026-07-30 20:51:54 +03:00

25 lines
1.1 KiB
C#

namespace StockSharp.Configuration;
/// <summary>
/// Fetches the credentials of the currently signed-in client.
/// </summary>
/// <remarks>
/// The credentials dialog needs exactly one thing from the web API - who is signed in and with
/// what token - and this is that one thing. Stating it here, next to ICredentialsProvider, rather
/// than taking the web API's own client service keeps the dependency pointing the right way: the
/// dialog does not need to know the shape of the web API, and the caller, which already knows it,
/// supplies the implementation.
/// </remarks>
public interface ICurrentClientFetcher
{
/// <summary>
/// Returns the signed-in client's email and access token.
/// </summary>
/// <param name="salt">
/// OAuth salt to wait on, or <see langword="null"/> for a plain "who am I" request.
/// </param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>The client's email and access token.</returns>
Task<(string email, SecureString accessToken)> FetchAsync(string salt, CancellationToken cancellationToken);
}