Created
March 26, 2021 09:34
-
-
Save creative-cranels/e6cd4648ad0cf28a17efd31d4d93f9b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ui := ctx.MustGet("user_info").(*model.UserInfo) | |
atClaims := jwt.MapClaims{} | |
atClaims["message"] = "hello" | |
atClaims["userID"] = ui.UserID | |
atClaims["now"] = time.Now().Add(time.Hour * 72).Unix() | |
atClaims["exp"] = time.Now().Add(time.Minute * 15).Unix() | |
var mySigningKey = "ASKS1298dn125568mJQ12=masd=09856nAnD=8J4" | |
token := jwt.NewWithClaims(jwt.GetSigningMethod("HS256"), atClaims) | |
tokenString, err := token.SignedString([]byte(mySigningKey)) | |
md5Token := fmt.Sprintf("%x", md5.Sum([]byte(tokenString))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment