jwt-go generating invalid signature tokens
Author: fabstaoCreated Jul 27, 2020Updated May 14, 2022
Hi!
I am trying to use jwt-go for authentication, but when I try to validate the token, I get: Error: signature is invalid
Sample token:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTU4MjYzOTAsInJvbCI6InVzdWFyaW8iLCJ1c2VyIjoiZmFicyJ9.EtWzy5_b6qUyD_-uyD9XJll5R0XWW6ntISBEohwGmo4It's invalid even checking in jwt.io
Code generating token:
token := jwt.New(jwt.SigningMethodHS256)
clamas := token.Claims.(jwt.MapClaims)
clamas["user"] = usuario.Username
clamas["rol"] = rol.Role
clamas["exp"] = time.Now().Add(time.Hour).Unix()
var err error
PToken, err = token.SignedString([]byte("el_secreto"))
if err != nil {
return err
}Is there anything special I should use for HMAC secret in token.SingnedString ?
Thanks!!
Source: dgrijalva/jwt-go