firebase / firebase-admin-go

Firebase Admin Go SDK
Apache License 2.0
1.12k stars 239 forks source link

how to login using email and password using golang sdk #628

Open vksssd opened 3 weeks ago

vksssd commented 3 weeks ago

how to login using email and password using golang sdk

[REQUIRED] : Want something similar to this

// EmailLoginHandler handles user login with email and password
func EmailLoginHandler(firebaseAuth *auth.Client) gin.HandlerFunc {
    return func(c *gin.Context) {
        var req EmailLoginRequest
        if err := c.ShouldBindJSON(&req); err != nil {
            utils.RespondWithError(c, http.StatusBadRequest, "Invalid request")
            return
        }

        // Authenticate user with email and password
        token, err := firebaseAuth.SignInWithEmailAndPassword(context.Background(), req.Email, req.Password)
        if err != nil {
            utils.RespondWithError(c, http.StatusUnauthorized, "Invalid email or password")
            return
        }

        c.JSON(http.StatusOK, gin.H{
            "message": "Login successful",
            "token":   token,
        })
    }
}

Method for signinwithemailandpassword is not available:

But SignInWithEmailAndPassword() is method is not available

google-oss-bot commented 3 weeks ago

I found a few problems with this issue: