Pat
Pat

Reputation: 323

To create JWT where to provide public key in this implementation

I see private key, but where to provide the public key so I can publish. Works perfectly but I am missing the public key, where is it given while creating the JWT token? I assume the example key (dnfksdmfksd) below is the private key. I am using github.com/dgrijalva/jwt-go Thanks!

func CreateToken(userid uint64) (string, error) {
    var err error
     //Creating Access Token
     os.Setenv("ACCESS_SECRET", "jdnfksdmfksd") //this should be in an env file
     atClaims := jwt.MapClaims{}
     atClaims["authorized"] = true
     atClaims["user_id"] = userid
     atClaims["exp"] = time.Now().Add(time.Minute * 15).Unix()
     at := jwt.NewWithClaims(jwt.SigningMethodHS256, atClaims)
     token, err := at.SignedString([]byte(os.Getenv("ACCESS_SECRET")))
     if err != nil {
       return "", err
     }
     return token, nil
   }

Upvotes: 0

Views: 326

Answers (1)

Burak Serdar
Burak Serdar

Reputation: 51642

HS256 is a symmetric algorithm. It uses a shared secret. There is not public/private key. The recipients of the JWT have to use the same secret to validate the signature.

Upvotes: 1

Related Questions