Hi i need some help Can you guys please tell me how can i create this go code which package and modules i need to import to complete this please provide me complete poc so i can make things work
func createToken(apiKey string, nonce int64, endpoint string, privateKey *x509.PrivateKey) string {
// Generate a JWT
token := jwt.NewWithClaims(jwt.SigningMethodES256, jwt.MapClaims{
"api-key": apiKey,
"nonce": nonce,
"uri": endpoint,
"exp": jwt.NewNumericDate(time.Now().Add(time.Hour * 72)),
})
tokenString, err := token.SignedString(privateKey)
if err != nil {
log.Fatal(err)
}
return tokenString
}
i want to view the response like this after base64 decode
{
"exp": 1694673536,
"api-key": "hsk_89c6d8a1d313461db1a37dd0d1f88661",
"uri": "/v1/validate",
"nonce": 4242658338,
"digest": "wij3HROZrND_YdAzUHHuqJUYgUchg7EKg8bPzCk3LMXOq9c00UxCL2g82A6TcPxoo2w_eWDDJUf-dD18vvOKLg=="
}
Thanks