An open API service indexing awesome lists of open source software.

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

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)
```