firebase:使用数据库密钥进行ruby身份验证

时间:2017-10-30 02:49:40

标签: ruby firebase firebase-realtime-database google-api firebase-authentication

重新询问same问题,因为:

 Database Secrets
warning
Database secrets are currently deprecated and use a legacy Firebase token generator. Update your source code with the Firebase Admin SDK.

获得“秘密”时 - 我推断它们意味着秘密密钥。

供参考:

thufir@dur:~/ruby/firebase$ 
thufir@dur:~/ruby/firebase$ ./quickstart.rb 
true
200
{"name"=>"-Kxf9rMd9p1F0cb2HTeM"}
thufir@dur:~/ruby/firebase$ 
thufir@dur:~/ruby/firebase$ cat quickstart.rb 
#!/usr/bin/env ruby


require 'rubygems'
require 'firebase'
require 'pp'
require_relative 'config'



config = Config.new

#firebase = Firebase::Client.new(config.database_url)
firebase = Firebase::Client.new(config.database_url,config.database_secret)


response = firebase.push("todos", { :name => 'Pick the milk', :priority => 1 })
pp response.success? # => true
pp response.code # => 200
pp response.body # => { 'name' => "-INOQPH-aV_psbk3ZXEX" }
response.raw_body # => '{"name":"-INOQPH-aV_psbk3ZXEX"}'


thufir@dur:~/ruby/firebase$ 
这种方法相对稳定吗?我从Google控制台GUI复制了信息:

Add Firebase to your web app

Copy and paste the snippet below at the bottom of your HTML, before other script tags.

进入配置文件以供参考。 (可能应该使用yaml或类似的;现在可以使用。)

0 个答案:

没有答案