dgrijalva / jwt-go

ARCHIVE - Golang implementation of JSON Web Tokens (JWT). This project is now maintained at:
https://github.com/golang-jwt/jwt
MIT License
10.78k stars 997 forks source link

key is of invalid type, []byte('key') - not working #451

Open yongDataScince opened 3 years ago

yongDataScince commented 3 years ago

`token := jwt.NewWithClaims(jwt.SigningMethodES256, &tokenClaims{ jwt.StandardClaims { ExpiresAt: time.Now().Add(tockenTTL).Unix(), IssuedAt: time.Now().Unix(), }, user.ID, })

signKey := []byte("kdnjsndjnd*jdnj212md")

tkn, err := token.SignedString(signKey)
return tkn, err`

Originally posted by @yongDataScince in https://github.com/dgrijalva/jwt-go/issues/65#issuecomment-776227353

huanghongqing commented 3 years ago

SigningMethodES256 ==> SigningMethodHS256