SignedString creates and returns a complete, signed JWT. The token is signed using the SigningMethod specified in the token. Please refer to https://golang-jwt.github.io/jwt/usage/signing_methods/#signing-methods-and-key-types for an overview of the different signing methods and their respective key
(key any)
| 61 | // for an overview of the different signing methods and their respective key |
| 62 | // types. |
| 63 | func (t *Token) SignedString(key any) (string, error) { |
| 64 | sstr, err := t.SigningString() |
| 65 | if err != nil { |
| 66 | return "", err |
| 67 | } |
| 68 | |
| 69 | sig, err := t.Method.Sign(sstr, key) |
| 70 | if err != nil { |
| 71 | return "", err |
| 72 | } |
| 73 | |
| 74 | t.Signature = sig |
| 75 | |
| 76 | return sstr + "." + t.EncodeSegment(sig), nil |
| 77 | } |
| 78 | |
| 79 | // SigningString generates the signing string. This is the most expensive part |
| 80 | // of the whole deal. Unless you need this for something special, just go |