Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 1.03 KB

README.md

File metadata and controls

51 lines (37 loc) · 1.03 KB

FireJWT

Test License

Decode and validate Google Firebase JWT tokens with Ruby and Go.

Usage

Ruby:

require 'firejwt'

# Init a validator
validator = FireJWT::Validator.new 'my-project'

# Decode a token
token = begin
  validator.decode('eyJh...YbQ') # => {'sub' => '[email protected]', 'aud' => 'my-project'}
rescue JWT::DecodeError
  nil
end

Go:

package main

import (
  "log"

  "github.com/bsm/firejwt"
)

func main() {
  vr, err := firejwt.New("my-project")
  if err != nil {
    log.Fatalln(err)
  }
  defer vr.Stop()

  tk, err := vr.Decode("eyJh...YbQ")
  if err != nil {
    log.Fatalln(err)
  }

  log.Println(tk.Claims) // => {"sub": "[email protected]", "aud": "my-project"}
}