Below is code to create user by firebase authentication.
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)
After create user, I want to send email link for sign-in automatically.Maybe it's possible by Node.js, Java, Python, and Go because they're supported officially. https://firebase.google.com/docs/auth/admin/email-action-links#node.js_3 Is there a way to do that by ruby-client? (I just want to send email below)
Even if ruby-client doesn't provide the option, you should be able to implement the API client from scratch like below. (Look up official document more carefully.)
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