File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,20 @@ JWT.encode(.HS256("secret")) { builder in
3939When decoding a JWT, you must supply one or more algorithms and keys.
4040
4141``` swift
42- JWT.decode (" eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w" , .HS256 (" secret" ))
42+ let result = JWT.decode (" eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w" , .HS256 (" secret" ))
43+
44+ switch result {
45+ case .Success (let payload):
46+ print (payload)
47+ case .Failure (let failure):
48+ print (" decoding failed \( failure ) " )
49+ }
4350```
4451
4552When the JWT may be signed with one out of many algorithms or keys:
4653
4754``` swift
48- JWT.decode (" eyJh...5w" , [.HS256 (" secret" ), .HS256 (" secret2" ), .HS512 (" secure" )])
55+ let result = JWT.decode (" eyJh...5w" , [.HS256 (" secret" ), .HS256 (" secret2" ), .HS512 (" secure" )])
4956```
5057
5158#### Supported claims
You can’t perform that action at this time.
0 commit comments