MCPcopy
hub / github.com/golang-jwt/jwt / MakeSampleToken

Function MakeSampleToken

test/helpers.go:36–45  ·  view source on GitHub ↗

MakeSampleToken creates and returns a encoded JWT token that has been signed with the specified cryptographic key.

(c jwt.Claims, method jwt.SigningMethod, key any)

Source from the content-addressed store, hash-verified

34
35// MakeSampleToken creates and returns a encoded JWT token that has been signed with the specified cryptographic key.
36func MakeSampleToken(c jwt.Claims, method jwt.SigningMethod, key any) string {
37 token := jwt.NewWithClaims(method, c)
38 s, e := token.SignedString(key)
39
40 if e != nil {
41 panic(e.Error())
42 }
43
44 return s
45}
46
47func LoadECPrivateKeyFromDisk(location string) crypto.PrivateKey {
48 keyData, e := os.ReadFile(location)

Callers 2

signTokenFunction · 0.92
TestParseRequestFunction · 0.92

Calls 2

SignedStringMethod · 0.80
ErrorMethod · 0.80

Tested by 2

signTokenFunction · 0.74
TestParseRequestFunction · 0.74