5.34Disabling Automatic Access Token Management
The framework has a built-in Access Token automatic management feature. You only need to implement the IHttpAccessTokenProvider interface and write the logic for obtaining the Access Token in the GetAsync method. Normally, obtaining an Access Token requires a separate HTTP request, and if you use IHttpRemoteService directly inside GetAsync to send the request, it will trigger the automatic management mechanism and fall into an infinite recursive loop. In this case, you need to explicitly disable Access Token automatic management for the current request by marking it with the [SuppressTokenManagement] attribute to avoid circular calls.
public class CustomHttpAccessTokenProvider(IHttpBaseService httpBaseService): IHttpAccessTokenProvider{ /// <inheritdoc /> public async Task<HttpAccessToken?> GetAsync(CancellationToken cancellationToken) { var serverToken = await httpBaseService.LoginAsync(new { username = "furion", password = "your-password"}); return new HttpAccessToken(serverToken.Token, serverToken.ExpiresAt) };}HTTP declarative requests disable the automatic Access Token management of the framework through the SuppressTokenManagementAttribute attribute. The corresponding HTTP declarative extractor implementation is the SuppressTokenManagementDeclarativeExtractor type, which is responsible for parsing the SuppressTokenManagementAttribute attribute and building the configuration required by the HttpRequestBuilder instance to disable the automatic Access Token management of the framework.
public interface IHttpService : IHttpDeclarative{ [Get("https://furion.net/")] [SuppressTokenManagement] // Skip Token management to avoid recursive calls Task<YourServerToken> LoginAsync(object auth); [Get("https://furion.net/")] Task<YourModel>> GetAsync(); // No marking required}If you need to disable this feature for a specific request, set the [JsonResponseStringUnwrap(false)] attribute.
SuppressTokenManagementAttribute contains the following constructors and properties:
None.