Skip to content

Commit

Permalink
Add example usage to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
LewisWatson committed Feb 21, 2017
1 parent 18e6505 commit 05ae396
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,23 @@ This library follows the instructions described in [verify id tokens using third

[Firebase]: https://firebase.google.com/ "Firebase"
[JWT]: https://jwt.io/ "JWT"

## Example Usage

```go
import (
"github.com/LewisWatson/firebase-jwt-auth"
"github.com/manyminds/api2go"
)

// tokenVerifier previously initialsed with fireauth.New("projectname")
func verify(r api2go.Request, tokenVerifier fireauth.TokenVerifier) error {
token := r.Header.Get("authorization")
userID, claims, err := tokenVerifier.Verify(token)
if err != nil {
return err
}
r.Context.Set("userID", userID)
r.Context.Set("claims", claims)
return nil
}

0 comments on commit 05ae396

Please sign in to comment.