using System;
using System.Text.Json.Serialization;
namespace Wabbajack.DTOs.OAuth;
///
/// JWT Token info as provided by the OAuth server
///
public class JwtTokenReply
{
///
/// the token to use for authentication
///
[JsonPropertyName("access_token")]
public string? AccessToken { get; set; }
[JsonPropertyName("_received_at")]
public long ReceivedAt { get; set; }
public bool IsExpired => DateTime.FromFileTimeUtc(ReceivedAt) + TimeSpan.FromSeconds(ExpiresIn) - TimeSpan.FromMinutes(5) <= DateTimeOffset.UtcNow;
///
/// token type, e.g. "Bearer"
///
[JsonPropertyName("token_type")]
public string? Type { get; set; }
///
/// when the access token expires in seconds
///
[JsonPropertyName("expires_in")]
public ulong ExpiresIn { get; set; }
///
/// token to use to refresh once this one has expired
///
[JsonPropertyName("refresh_token")]
public string? RefreshToken { get; set; }
///
/// space separated list of scopes. defined by the server, currently always "public"?
///
[JsonPropertyName("scope")]
public string? Scope { get; set; }
///
/// unix timestamp (seconds resolution) of when the token was created
///
[JsonPropertyName("created_at")]
public long CreatedAt { get; set; }
}