https://github.com/bsm/firejwt
Validation for Firebase JWT
https://github.com/bsm/firejwt
Last synced: about 1 year ago
JSON representation
Validation for Firebase JWT
- Host: GitHub
- URL: https://github.com/bsm/firejwt
- Owner: bsm
- License: apache-2.0
- Created: 2020-01-22T13:58:15.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-08-01T23:16:33.000Z (almost 2 years ago)
- Last Synced: 2025-03-22T19:02:22.993Z (about 1 year ago)
- Language: Go
- Size: 45.9 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FireJWT
[](https://github.com/bsm/firejwt/actions/workflows/test.yml)
[](https://opensource.org/licenses/Apache-2.0)
Decode and validate [Google Firebase](https://firebase.google.com/) JWT tokens with [Ruby](https://www.ruby-lang.org/) and [Go](https://golang.org/).
## Usage
**Ruby**:
```ruby
require 'firejwt'
# Init a validator
validator = FireJWT::Validator.new 'my-project'
# Decode a token
token = begin
validator.decode('eyJh...YbQ') # => {'sub' => 'me@example.com', 'aud' => 'my-project'}
rescue JWT::DecodeError
nil
end
```
**Go**:
```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": "me@example.com", "aud": "my-project"}
}
```