Skip to content

Commit 7cdeb79

Browse files
authored
Merge pull request #7 from railscltgroup/readme
Readme
2 parents 0f037eb + fd291de commit 7cdeb79

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@ https://firebase.google.com/docs/auth/admin/verify-id-tokens
77

88
Unfortunately, it appears Google does not have support for Ruby. So, I made my own auth file!
99

10-
This gem is an extraction of that file and is still in development.
10+
## Installation:
11+
#### Using Rubygems:
12+
```
13+
gem install firebase-token-verify
14+
```
1115

12-
If you can't wait for the gem to be finished, you're welcome to checkout the lib directory and add the code to your system as needed.
16+
#### Using Bundler
17+
Add `gem 'firebase-token-verify'` to your Gemfile and run `bundle install`
18+
19+
## Example use-case scenario:
20+
1) Lookup your firebase id and add it to your Ruby code, for example: `PROJECT_ID = <your_firebase_project_id>`
21+
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:
22+
```sh
23+
user.getIdToken(true).then(token => {
24+
// Send this token to your Ruby application
25+
})
26+
```
27+
3) Setup some Ruby code to process the token
28+
```sh
29+
require 'firebase_ruby_auth'
30+
31+
class FirebaseRubyAuthWrapper
32+
PROJECT_ID = ENV['<your_firebase_project_id>']
33+
34+
def initialize
35+
@auth = FirebaseRubyAuth.new(PROJECT_ID)
36+
end
37+
38+
def retrieve_email_from_token(token)
39+
@auth.decode_token(token)['email']
40+
end
41+
end
42+
```

firebase_ruby_auth.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift File.expand_path('lib', __dir__)
44

55
Gem::Specification.new do |s|
66
s.name = 'firebase-token-verify'
7-
s.version = '0.0.7'
7+
s.version = '0.1.0'
88
s.date = '2019-05-30'
99
s.summary = 'Authenticate Firebase User Tokens in Ruby'
1010
s.description = 'Firebase Ruby Auth'

0 commit comments

Comments
 (0)