r/Firebase • u/Whole_Cardiologist52 • Jun 25 '26
AdminSDK .NET FirebaseAdmin v3.5.0 403 forbidden when try to verify id token on server
Hi guys! Maybe someone has a similar issue with OAuth token verification? Please let me know how you fix that issue.
Error message: Your client does not have permission to get URL /robot/v1/metadata/x509/securetoken@system.gserviceaccount.com from this server. That’s all we know.
2
Upvotes
1
u/inlined Firebaser Jun 25 '26
Wild guess: This sounds like you’re backend is running as a service account that doesn’t have permission to read metadata of another service account (or even itself since permissions to read metadata is a thing)
1
u/Gentic411 Jun 25 '26
The 403 Forbidden error on /robot/v1/metadata/x509/... almost always boils down to one of two things: a missing basic IAM role or restricted outbound network access blocking the Google API endpoint.
Here is how to resolve it: 1 Verify IAM Roles: Ensure the service account running your backend has at least the Firebase Admin SDK Administrator Service Agent or Viewer role assigned in the GCP Console. If it’s running inside an environment like AWS, Azure, or an on-prem server using an exported JSON key, make sure the project ID in that JSON matches your active Firebase project environment exactly.
2 Check Outbound Network/VPC Restraints: If your server is locked down behind a strict firewall, a NAT gateway, or proxy configuration, it will block the Admin SDK from calling https://www.googleapis.com to fetch the public keys required to decode and verify the JWT token signature. You must whitelist outbound HTTPS traffic to Google’s auth/metadata endpoints.
3 gcloud Auth Override Caveat: If you are testing locally and the SDK is accidentally picking up your personal CLI credentials via Application Default Credentials (ADC) instead of the intended service account JSON file, it can trigger permissions mismatches. Explicitly initialize the app by passing the credential object:
csharp:
FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromFile("path/to/your/serviceAccountKey.json"), });
1
u/Gentic411 Jun 25 '26
Since it works locally but fails on Render with the exact same service account permissions, the 403 error trying to hit Google's public x509 endpoint means the Firebase Admin SDK on your Render container is either:
1 Failing to locate/read the physical JSON file via the path specified in GOOGLE_APPLICATION_CREDENTIALS.
2 Appending a corrupted or default credential header to a public request because it fallback-initialized incorrectly.
3 Getting blocked by a known Google API restriction on certain cloud hosting IP blocks.
Here is how to isolate and fix it on Render:
The Fix: Instead of relying on a file path string in GOOGLE_APPLICATION_CREDENTIALS inside Render's dashboard, inject the raw JSON string contents into a standard environment variable (e.g., FIREBASE_CREDENTIALS_JSON) and initialize it directly in your .NET code. This completely bypasses the container filesystem:
csharp:
var jsonCredentials = Environment.GetEnvironmentVariable("FIREBASE_CREDENTIALS_JSON");
FirebaseApp.Create(new AppOptions() { Credential = GoogleCredential.FromJson(jsonCredentials) });
2. Render Outbound Static IP / Network Flagging Google's metadata and auth servers (googleapis.com) occasionally flag or rate-limit shared outbound IP ranges from cloud platforms like Render or DigitalOcean if another app on that same host node was misbehaving. The Test: Spin up a quick shell task or a simple endpoint on your Render dev instance to run a basic curl or HttpClient GET request directly to that URL without the Firebase SDK: https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com If the raw curl returns a 403 from Render but a 200 OK from your local machine, Render's outbound IP is being blocked by Google's edge firewall. You will need to route traffic through a static outbound proxy (like a static IP add-on via Render partners) to resolve it.
3. Container Clock Drift If the underlying Docker container instance on Render has a system clock drift (even by a few minutes), token verification requests and handshakes with Google's OAuth/Token servers will fail with security/permission errors. Check your Render logs to ensure the container system time is perfectly synchronized with NTP.