step-up-labs / firebase-authentication-dotnet

C# library for Firebase Authentication
MIT License
376 stars 129 forks source link

Sign in with google #221

Closed Lukakeiton closed 1 month ago

Lukakeiton commented 1 month ago

Good morning,

I am programming on MAUI using .NET 8.0 to implement Google login using firebase.

I have the code to login to Google and retrieve the token when success.

I use this token to authenticate to firebase but not success.

Here is the function I have made to Google login in Firebase.

public async Task LoginGoogle(string token) { var credential = GoogleProvider.GetCredential(token); var res = await client.SignInWithCredentialAsync(credential); if (res != null) { //Save user properties } }

When await client.SignInWithCredentialAsync(credential) is executed I get this exception:

`Firebase.Auth.FirebaseAuthHttpException: 'Exception occured during Firebase Http request. Url: https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?key=API_KEY_FROM_FIREBASE Request Data: {"requestUri":"https://reservastuba.firebaseapp.com","postBody":"access_token=TOKEN_FROM_GOOGLE&providerId=google.com","returnIdpCredential":true,"returnSecureToken":true} Response: { "error": { "code": 400, "message": "INVALID_IDP_RESPONSE : Unsuccessful check authorization response from Google: {\n \"error_description\": \"Invalid Value\"\n}\n", "errors": [ { "message": "INVALID_IDP_RESPONSE : Unsuccessful check authorization response from Google: {\n \"error_description\": \"Invalid Value\"\n}\n", "domain": "global", "reason": "invalid" } ] } }

Reason: Unknown' `

If I use email and password providers, I can login in firebase successfully.

Is there any way (not looking for code) to achieve that?

I am using Microsoft Visual Studio Community 2022 (64 bits) - Current Versión 17.10.0 and last version of the nuget package (FirebaseAuthentication.net 4.1.0).

Thank you in advance.