通过 firebase 身份验证创建用户后,是否可以生成电子邮件验证 link 并将其发送给用户?

After create user by firebase authentication, is there a way to generate email verification link and send it to the user?

以下是通过 firebase 身份验证创建用户的代码。

require 'google/apis/identitytoolkit_v3'

service_account = "./firebase-auth.json"

service = Google::Apis::IdentitytoolkitV3::IdentityToolkitService.new
service.authorization = Google::Auth::ServiceAccountCredentials.make_creds(
  json_key_io: File.open(service_account),
  scope: 'https://www.googleapis.com/auth/identitytoolkit'
)

request = Google::Apis::IdentitytoolkitV3::SignupNewUserRequest.new(
  email: 'sample@example.com',
  email_verified: false
)
service.signup_new_user(request)

创建用户后,我想发送电子邮件 link 用于登录 automatically.Maybe 可以通过 Node.js、Java、Python 和去吧,因为他们得到了官方支持。 https://firebase.google.com/docs/auth/admin/email-action-links#node.js_3 ruby-client 有没有办法做到这一点? (我只想在下面发送电子邮件)

Email template at firebase console

即使 ruby-client 不提供该选项,您也应该能够像下面这样从头开始实现 API 客户端。 (仔细查看 official document。)

require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=[YOUR_API_KEY]")
request = Net::HTTP::Post.new(uri)
request.content_type = "application/json"
request.body = JSON.dump({requestType: "PASSWORD_RESET",email: "[EMAIL_OF_THE_USER]"})
response = Net::HTTP.start(uri.host, uri.port, { use_ssl: true }) do |http|
  http.request(request)
end