forked from mirror/jwt
parent
f80fd39457
commit
ba4268888e
11
README.md
11
README.md
|
@ -5,9 +5,9 @@ This library supports the parsing and verification as well as the generation and
|
||||||
This library is considered production ready. Feedback and feature requests are appreciated.
|
This library is considered production ready. Feedback and feature requests are appreciated.
|
||||||
|
|
||||||
## Parse and Verify
|
## Parse and Verify
|
||||||
|
```go
|
||||||
token, err := jwt.Parse(myToken, func(token *jwt.Token) ([]byte, error) {
|
token, err := jwt.Parse(myToken, func(token *jwt.Token) ([]byte, error) {
|
||||||
return myLookupKey(token.Head["kid"])
|
return myLookupKey(token.Header["kid"])
|
||||||
})
|
})
|
||||||
|
|
||||||
if !err && token.Valid {
|
if !err && token.Valid {
|
||||||
|
@ -15,10 +15,15 @@ This library is considered production ready. Feedback and feature requests are
|
||||||
} else {
|
} else {
|
||||||
deliverUtterRejection(":(")
|
deliverUtterRejection(":(")
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Create a token
|
## Create a token
|
||||||
|
|
||||||
token := jwt.New(jwt.GetSigningMethod("HS256"))
|
```go
|
||||||
|
token, _ := jwt.New(jwt.GetSigningMethod("HS256"))
|
||||||
token.Claims["foo"] = "bar"
|
token.Claims["foo"] = "bar"
|
||||||
token.Claims["exp"] = time.Now().Add(time.Hour * 72).Unix()
|
token.Claims["exp"] = time.Now().Add(time.Hour * 72).Unix()
|
||||||
tokenString, err := token.SignedString(mySigningKey)
|
tokenString, err := token.SignedString(mySigningKey)
|
||||||
|
```
|
||||||
|
|
||||||
|
Documentation can be found [here](http://godoc.org/github.com/dgrijalva/jwt-go)
|
Loading…
Reference in New Issue