I need to authenticate through email and password when signing up in my angular app. The required auth.service. and onSubmit method are as follows. Email and password sign in providers are enabled in firebase authentication section.
auth.service.ts
signup(email: string, password: string) {
return this.http.post('https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=[REPLACE_WITH_MY_API_KEY]', {
email: email,
password: password,
returnSecureToken: true
})
}
auth.component.ts
onSubmit(form: NgForm) {
if (!form.valid) {
return;
}
const email = form.value.email;
const password = form.value.password;
if (this.isLoginMode) {
//....
} else {
this.authService.signup(email, password).subscribe(responseData => {
console.log(responseData);
}, err => {
console.log(err);
});
}
form.reset();
}
According to the firebase documentation , a token parameter should be passed to this. How to generate it and add it in this signup method?. A 400 error occurs when executing the method in this way.