I met this issue and really do not know how to resolve it, can anyone help to provide a working solution?
func GenerateJWT(name, role string) (string, error) {
//create a singner for rsa 256
claims := &jwt.StandardClaims{
ExpiresAt: 15000,
Issuer: "test",
}
token :=jwt.NewWithClaims(jwt.SigningMethodES256, claims)
log.Println("generated toke is ")
log.Println(token)
tokenString, err := token.SignedString([]byte("secret"))
....
}
Now I am alway having:
key is of invalid type
error. I google a lot, and even for jwt-go
library it self, they are providing exactly same solution, but why I kept having the
key is of invalid type
error?
Can anyone help to provide a working sample about how to generate jwt
token in go
?