Skip to content

Instantly share code, notes, and snippets.

@AlexKalinin
Created August 4, 2017 19:06
Show Gist options
  • Save AlexKalinin/92ddcd590c2046dc3074950e4fa530d6 to your computer and use it in GitHub Desktop.
Save AlexKalinin/92ddcd590c2046dc3074950e4fa530d6 to your computer and use it in GitHub Desktop.
Firebase example, ruby
# https://github.com/oscardelben/firebase-ruby
# https://github.com/firebase/firebase-token-generator-ruby
# Gemfile
# gem 'firebase'
# gem 'firebase_token_generator'
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default)
fb_url = 'https://<DATABASE_NAME>.firebaseio.com'
payload = {:uid => "1", :auth_data => "foo", :other_auth_data => "bar"}
# https://console.firebase.google.com/project/<DATABASE_NAME>/settings/serviceaccounts/databasesecrets
generator = Firebase::FirebaseTokenGenerator.new('<SECRET_KEY>')
token = generator.create_token(payload)
fb = Firebase::Client.new(fb_url, token)
result = fb.get('clients', {orderBy: '"$key"', :startAt => '"ZXCVSSXCVV23655446"'})
binding.pry
puts result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment