|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace GDZZ.Core;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// AccessToken参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class TokenModel
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 会话密钥
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonPropertyName("session_key")]
|
|
|
|
|
public string SessionKey { get ;set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 平台唯一标识
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonPropertyName("unionid")]
|
|
|
|
|
public string Unionid { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 错误码
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonPropertyName("errcode")]
|
|
|
|
|
public int ErrCode { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 错误信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonPropertyName("errmsg")]
|
|
|
|
|
public string Errmsg { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 用户标识
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonPropertyName("openid")]
|
|
|
|
|
public string OpenId { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// AccessToken
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonPropertyName("access_token")]
|
|
|
|
|
public string AccessToken { get; set; }
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// Token 类型
|
|
|
|
|
///// </summary>
|
|
|
|
|
//[JsonPropertyName("token_type")]
|
|
|
|
|
//public string TokenType { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 用于刷新 AccessToken 的 Token
|
|
|
|
|
///// </summary>
|
|
|
|
|
//[JsonPropertyName("refresh_token")]
|
|
|
|
|
//public string RefreshToken { get; set; }
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 此 AccessToken 对应的权限
|
|
|
|
|
///// </summary>
|
|
|
|
|
//[JsonPropertyName("scope")]
|
|
|
|
|
//public string Scope { get; set; }
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// AccessToken 过期时间
|
|
|
|
|
///// </summary>
|
|
|
|
|
//[JsonPropertyName("expires_in")]
|
|
|
|
|
//public dynamic ExpiresIn { get; set; }
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 错误的详细描述
|
|
|
|
|
///// </summary>
|
|
|
|
|
//[JsonPropertyName("errordescription")]
|
|
|
|
|
//public string ErrorDescription { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class AccessTokenModelModelExtensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取的Token是否包含错误
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="accessTokenModel"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static bool HasError(this TokenModel accessTokenModel)
|
|
|
|
|
{
|
|
|
|
|
return accessTokenModel == null || !string.IsNullOrEmpty(accessTokenModel.Errmsg);
|
|
|
|
|
}
|
|
|
|
|
}
|