Skip to content

Commit

Permalink
Merge pull request kylef#11 from Deekor/patch-1
Browse files Browse the repository at this point in the history
Updated the readme to show a better example of decoding. I cant be th…
  • Loading branch information
kylef committed Sep 10, 2015
2 parents ed2159a + 63cf8e8 commit 486140c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,20 @@ JWT.encode(.HS256("secret")) { builder in
When decoding a JWT, you must supply one or more algorithms and keys.

```swift
JWT.decode("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w", .HS256("secret"))
let result = JWT.decode("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.2_8pWJfyPup0YwOXK7g9Dn0cF1E3pdn299t4hSeJy5w", .HS256("secret"))

switch result {
case .Success(let payload):
print(payload)
case .Failure(let failure):
print("decoding failed \(failure)")
}
```

When the JWT may be signed with one out of many algorithms or keys:

```swift
JWT.decode("eyJh...5w", [.HS256("secret"), .HS256("secret2"), .HS512("secure")])
let result = JWT.decode("eyJh...5w", [.HS256("secret"), .HS256("secret2"), .HS512("secure")])
```

#### Supported claims
Expand Down

0 comments on commit 486140c

Please sign in to comment.