Authorization签名

更新时间: 2023-10-23 16:45:52

# Authorization签名

HEADER
{
    "alg": "HS256", // 对称算法
    "typ": "JWT"
}
PAYLOAD
{
    "appid": "3098a8", // 申请appid
    "timestamp": 1644132513 // 时间戳
}

密钥:申请appSecret 申请appId, appSecret,生成jwt签名

type MyCustomClaims struct {
   jwt.StandardClaims
   Appid     string `json:"appid"`
   Timestamp int64  `json:"timestamp"`
}

// Create the Claims
claims := MyCustomClaims{
   jwt.StandardClaims{},
   appId, // 申请appid
   time.Now().Unix(),
}

token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
return token.SignedString([]byte(appSecret))

# 状态码说明

状态码 说明
10000 成功
10001 签名失败
10003 参数错误
20000 操作失败