Memo
rails RailsでFirebaseUserの作成/取得など
Home
›
Memo
›
RailsでFirebaseUserの作成/取得など
本稿について
本稿はサイト運営者が学んだことなどを記したメモの内容です。
全てが正確な情報とは限りません。ご注意ください。また修正するべき点は適時修正していきます
RubyにはFirebase SDKなどのライブラリは 2020年5月現在存在しないが、FIrebaseUserの作成や取得ができたのでメモ
Gem
“google-api-client” を利用する
“google-cloud-bigquery” でも “google-api-client” がインストールされる
gem 'google-api-client’
~~ or ~~
gem 'google-cloud-bigquery'
GCP_AUTH_KEY_FILEはGoogle Cloud Platformより取得
https://cloud.google.com/docs/authentication/production?hl=ja
require 'google/apis/identitytoolkit_v3'
class FirebaseAuth
def self.create(email, password)
service = Google::Apis::IdentitytoolkitV3::IdentityToolkitService.new
auth = Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: File.open(Rails.root.join('config/firebase_admin', ENV['GCP_AUTH_KEY_FILE'])),
scope: ['https://www.googleapis.com/auth/identitytoolkit']
)
service.authorization = auth
user_data = {
email: email,
email_verified: true,
password: password,
disabled: false
}
request = Google::Apis::IdentitytoolkitV3::SignupNewUserRequest.new(user_data)
service.signup_new_user(request)
end
end
[参考]
https://qiita.com/asflash8/items/17775895e35272ae7ec8
https://blog.takeyuweb.co.jp/entry/2020/04/23/100000
https://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/IdentitytoolkitV3/IdentityToolkitService#verify_password-instance_method
関連ページ
RailsでTogglと通信
#rails
2020-08-10 14:49:38
RailsでBasic認証
#rails
2020-11-17 14:27:26
Railsでapple storeのレシート検証
#rails
2020-07-24 20:57:30
サイトマップの作成
#rails
2020-06-02 22:00:19
seed
#rails
2020-06-29 19:02:25
Back