This library follows the instructions described in verify id tokens using third-party JWT library section of the firebase documentation.
import (
"gopkg.in/LewisWatson/firebase-jwt-auth.v1"
"github.com/manyminds/api2go"
)
// tokenVerifier previously initialised 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
}