using Newtonsoft.Json;

namespace NPin.Framework.AspNetCore.Authentication.OAuth;

public class AuthenticationErrCodeModel
{
    [JsonProperty(PropertyName = "error")] public string Error { get; set; }

    [JsonProperty(PropertyName = "error_description")]
    public string ErrorDescription { get; set; }

    public static void VerifyErrResponse(string content)
    {
        var model = JsonConvert.DeserializeObject<AuthenticationErrCodeModel>(content);
        if (model.Error != null)
        {
            throw new Exception($"第三方授权返回错误 错误码 [{model.Error}] 错误详情 [{model.ErrorDescription}]");
        }
    }
}