1. Home
  2. Docs
  3. golang
  4. jwt

jwt

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?

issues-解答

相关资料

[github-jwt]()

Was this article helpful to you? Yes No

How can we help?