Skip to content

Commit

Permalink
Add godoc example
Browse files Browse the repository at this point in the history
  • Loading branch information
LewisWatson committed Feb 21, 2017
1 parent 69acb77 commit 349be70
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package fireauth_test

import (
"io/ioutil"
"log"

"github.com/LewisWatson/firebase-jwt-auth"
)

func ExampleVerify() {

fireauth, err := fireauth.New("example project")
if err != nil {
log.Fatalf("%v", err)
}

token, err := getToken()
if err != nil {
log.Fatalf("%v", err)
}

userID, claims, err := fireauth.Verify(token)
if err != nil {
log.Fatalf("%v", err)
}

log.Printf("userID %v, claims %+v", userID, claims)
}

func getToken() (string, error) {
content, err := ioutil.ReadFile("testdata/token.txt")
if err != nil {
return "", err
}

return string(content), nil
}

0 comments on commit 349be70

Please sign in to comment.