I'm trying to make post requests to Firebase URL but it's giving a 400 error

Discussão em 'Angular' iniciado por viniideveloper, Dezembro 18, 2024.

  1. I'm trying to make post requests to the Firebase Auth REST API, at the following url: httpss://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[my key]

    but I'm getting the following error in my console after trying to login "Http failure response for httpss://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=AIzaSyDThl5AbjP3GU4XvtdpBn5ZvVUFVXMJMSA: 400 OK"

    my login method to the service

    login(data: any): Observable<UserAuth>{
    console.log(data)
    var url: string = this.FIREBASE_URL + 'v1/accounts:signInWithPassword?key=AIzaSyDThl5AbjP3GU4XvtdpBn5ZvVUFVXMJMSA' +
    this.TOKEN_FIREBASE
    console.log(url)
    return this.segurancaHttp.post<UserAuth>(url, data, httpOptions)


    }

    my login.component method

    onSubmit(): void {
    if (this.autorizacaoService.obterLoginStatus()) {
    this.autorizacaoService.deslogar()
    } else {
    this.service.login(this.addressForm.value).subscribe({

    next: (response) => {
    console.log(response.idToken)
    if(response.idToken){
    this.autorizacaoService.autorizar(response.idToken)

    this.route.navigate(['/usuario'])
    }

    },


    error: (erro: any) => {
    console.log(erro)
    alert('Ocorreu algum erro')
    }
    })
    }
    }


    It is worth mentioning that I am using version 17 of Angular

    Continue reading...

Compartilhe esta Página