https://github.com/railscltgroup/firebase_auth
Authenticate Firebase User Tokens in Ruby
https://github.com/railscltgroup/firebase_auth
firebase firebase-token jwt ruby rubygem
Last synced: 10 months ago
JSON representation
Authenticate Firebase User Tokens in Ruby
- Host: GitHub
- URL: https://github.com/railscltgroup/firebase_auth
- Owner: railscltgroup
- Created: 2019-03-30T17:40:42.000Z (about 7 years ago)
- Default Branch: release
- Last Pushed: 2020-08-29T13:43:40.000Z (almost 6 years ago)
- Last Synced: 2025-07-23T13:18:51.198Z (11 months ago)
- Topics: firebase, firebase-token, jwt, ruby, rubygem
- Language: Ruby
- Size: 33.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ruby Firebase Auth
I have a Rails App where I need to authenticate firebase users on the server-side, not just in JavaScript.
I found these instructions from google:
https://firebase.google.com/docs/auth/admin/verify-id-tokens
Unfortunately, it appears Google does not have support for Ruby. So, I made my own auth file!
## Installation:
#### Using Rubygems:
```
gem install firebase-token-verify
```
#### Using Bundler
Add `gem 'firebase-token-verify'` to your Gemfile and run `bundle install`
## Example use-case scenario:
1) Lookup your firebase id and add it to your Ruby code, for example: `PROJECT_ID = `
2) Obtain a user token. You will need to be connected with JavaScript, or a mobile app, to obtain the user token. I usually obtain a user token using a JavaScript method similar to the one below:
```sh
user.getIdToken(true).then(token => {
// Send this token to your Ruby application
})
```
3) Setup some Ruby code to process the token
```sh
require 'firebase_ruby_auth'
PROJECT_ID = ENV['']
FirebaseRubyAuth.new(PROJECT_ID).decode_token(token)
```