"github.com/lestrrat-go/jwx/jwa"
"github.com/lestrrat-go/jwx/jwk"
"github.com/lestrrat-go/jwx/jws"
"github.com/lestrrat-go/jwx/jwt"
// Replace "myapp" with your app ID here.
// Replace "mykid" with the key ID you see in the portal.
// Replace the following call with your own way to get the private key.
f, err := os.Open("private-key.pem")
jwkSet, err := jwk.ParseReader(f, jwk.WithPEM(true))
_ = payload.Set(jwt.AudienceKey, AppID)
_ = payload.Set(jwt.IssuedAtKey, now.Unix())
_ = payload.Set(jwt.ExpirationKey, now.Add(5*time.Minute).Unix())
// The alg MUST be RS256.
hdr.Set("alg", alg.String())
buf, err := json.Marshal(payload)
token, err := jws.Sign(buf, alg, key, jws.WithHeaders(hdr))
fmt.Printf("%v\n", string(token))