Files
quantconnect--lean/Brokerages/Authentication/AccessTokenMetaDataResponse.cs
T
Roman Yavnikov ad1f1c629c
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
Refactor: minor cleanup (#8886)
* feat: Get AccessToken from Lean API

* feat: create TokenCredentials DTO instead of Tuple

* remove: extra unrequired null reference exceptions on argument check

* remove: SendAsync override in TokenHandler

* feat: override SendAsync in TokenHandler to prevent future bugs

* test:feat: SyncAsync in TokenHandler

* refactor: name property of AccessTokenExpires to Expiration in AccessTokenMetaDataResponse

* feat: add retry logic to getAccessToken in TokenHandler
test:feat: TokenHandler with retry logic

* feat: make retry timeout configurable in ctor
2025-07-24 19:25:54 -03:00

55 lines
2.1 KiB
C#

/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using QuantConnect.Api;
namespace QuantConnect.Brokerages.Authentication
{
/// <summary>
/// Represents a response containing metadata about an access token issued by Lean.
/// </summary>
public abstract class AccessTokenMetaDataResponse : RestResponse
{
/// <summary>
/// Gets the access token provided by Lean.
/// </summary>
public string AccessToken { get; }
/// <summary>
/// Gets the type of the token (e.g., "Bearer").
/// </summary>
public TokenType TokenType { get; }
/// <summary>
/// Gets the UTC expiration timestamp of the access token, with a 1-minute safety buffer applied.
/// </summary>
public DateTime Expiration { get; protected set; }
/// <summary>
/// Initializes a new instance of the <see cref="AccessTokenMetaDataResponse"/> class.
/// </summary>
/// <param name="accessToken">The access token string provided by the authentication service.</param>
/// <param name="tokenType">The type of the token (e.g., Bearer).</param>
/// <param name="expires">The expiration time of the access token (in UTC), with safety buffer applied.</param>
protected AccessTokenMetaDataResponse(string accessToken, TokenType tokenType, DateTime expires)
{
AccessToken = accessToken;
TokenType = tokenType;
Expiration = expires;
}
}
}