Skip to content

Commit fd291de

Browse files
committed
Updated readme
1 parent ec0359b commit fd291de

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
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+
```

0 commit comments

Comments
 (0)