Reputation: 899
When reading the firebase emulator documentation, I saw that it mentioned a REST API that would expose endpoints to create users. I have found the docs to create users but they don't seem to be for the emulator.
I've tried using the sample requests for signup but with the auth emulator domain (localhost:9099
). I've tried copying the example requests specifically for the auth emulator but changing it to mimic how the signup api looks like, none of this has worked however and they have just thrown 404s.
Does anyone have a sample request that can be made to create a user in the firebase emulator? Or is this something we need to create client code for?
Upvotes: 3
Views: 1920
Reputation: 3130
I think I figured it out. I followed the HTTP requests being made from the emulator web UI and this is what worked for me:
await fetch(`http://localhost:9099/identitytoolkit.googleapis.com/v1/accounts:signUp?key=${config.firebase.apiKey}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: '[email protected]',
password: 'pass1234',
returnSecureToken: true,
}),
});
And for completeness sake, here's how I clear out the users:
await fetch(`http://localhost:9099/emulator/v1/projects/${config.firebase.projectId}/accounts`, {
method: 'DELETE',
});
Upvotes: 8