Hi guys!
My game is running API calls to a .NET web app i have locally (will migrate it to Cloud Run at a later stage), for the life of me i cannot get the Firebase to see it authenticated, basically the Client (Unity) sends an API call to the web app and the web app tries to access Realtime DB, it all works well if the rules of the DB are open, i can read/write directly from the API any information, but as soon i limit the rules to “auth only” i can no longer access it via the API, but it does work via Client (Unity), what could i possibly be doing wrong?
I will leave here the files if anyone wants to take a peak at them.
FirebaseAuthMiddleware.cs (1.9 KB)
Startup.cs (1.8 KB)
ControllerA.cs (3.5 KB)
Also this is the Docker logs when i do an API call:
2024-10-09 20:50:23 info: Microsoft.Hosting.Lifetime[14]
2024-10-09 20:50:23 Now listening on: http://[::]:8080
2024-10-09 20:50:23 info: Microsoft.Hosting.Lifetime[0]
2024-10-09 20:50:23 Application started. Press Ctrl+C to shut down.
2024-10-09 20:50:23 info: Microsoft.Hosting.Lifetime[0]
2024-10-09 20:50:23 Hosting environment: Production
2024-10-09 20:50:23 info: Microsoft.Hosting.Lifetime[0]
2024-10-09 20:50:23 Content root path: /app
2024-10-09 20:50:34 warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
2024-10-09 20:50:34 Failed to determine the https port for redirect.
2024-10-09 20:50:34 info: MyApi.Firebase.FirebaseAuthMiddleware[0]
2024-10-09 20:50:34 User authenticated: hwqtyfFxf2Z3nqlb3Bve2USu2Or2
2024-10-09 20:50:34 info: MyApi.Controllers.ControllerA[0]
2024-10-09 20:50:34 ProcessData2 called with VariableA: 5, VariableB: 10
2024-10-09 20:50:34 fail: MyApi.Firebase.FirebaseAuthMiddleware[0]
2024-10-09 20:50:34 Error occurred during authentication
2024-10-09 20:50:34 Firebase.Database.FirebaseException: Exception occured while processing the request.
2024-10-09 20:50:34 Url: https://idle-game-e8a28-default-rtdb.europe-west1.firebasedatabase.app/general/aaa/bbb/.json
2024-10-09 20:50:34 Request Data:
2024-10-09 20:50:34 Response: {
2024-10-09 20:50:34 "error" : "Permission denied"
2024-10-09 20:50:34 }
2024-10-09 20:50:34
2024-10-09 20:50:34 ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
2024-10-09 20:50:34 at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
2024-10-09 20:50:34 at Firebase.Database.Query.FirebaseQuery.OnceSingleAsync[T](Nullable`1 timeout)
Any help is much appreciated, thank you ![]()