go get -u github.com/dgrijalva/jwt-go
安装
// 生成一个token
token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
"foo": "bar",
"nbf": time.Date(2021, 10, 10, 12, 0, 0, 0, time.UTC).Unix(),
})
// Sign and get the complete encoded token as a string using the secret
tokenString, err := token.SignedString([]byte("user:1:admin"))
fmt.Println(tokenString, err)
FAQ
key is invalid or of invalid type?
相关资料
[github-jwt]()