Urgent.News

What's breaking now, across hundreds of outlets.

Tech

How to get a Firebase ID token for testing your API (without writing a script)

Your backend verifies Firebase ID tokens. You want to call it from curl or Postman as a specific user. Firebase gives you no button for that. The usual answers are a sign-in REST call with an email and password (only works for password users), the Auth emulator (not your real project), or a small Admin SDK script that creates a custom token and exchanges it. I wrote that script one too many…

To obtain a Firebase ID token for testing your API without writing a script, follow these steps:

1. Download the Firebase Token Toolkit, a desktop app that simplifies the process.

2. Launch the app and browse for your service-account JSON file.

3. Click "Load apps" to import your project's web, Android, and iOS apps, along with their API keys.

4. Select a user from the list and click "Generate" to create a custom token for that user using the service-account key.

5. The toolkit will return a real ID token, refresh token, and expiry information. This token is identical to one a client would receive after signing in, so it will pass verification on your server.

6. Use the ID token in your API calls by adding it to the Authorization header, like so: `curl -H "Authorization: Bearer ID token" https://localhost:8080/api/me`.

7. The toolkit also handles custom claims and App Check tokens, making it a comprehensive solution for your testing needs.

Keep in mind that this method requires a development project, as the service-account key can sign in as any user and communicate with real Firebase. The ID token obtained will be valid for approximately an hour. The Firebase Token Toolkit is a native Rust app available for Linux, Windows, and macOS, and is MIT licensed with no telemetry.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

I Built a GPA Calculator in Vanilla JavaScript — Here's the Grade Math Nobody Explains

A while back I needed a GPA calculator that wasn't buried under popups and didn't ask me to create an account. So I built one. It sounded like a weekend project.

  • GPA calculation varies by school, requiring configurable grading scale
  • Weighted GPA differs by institution, use unweighted GPA as base
  • Calculator lets users choose grade replacement or averaging method

Flash Loan Attack Vector Analysis: Sky Lending

Flash Loan Attack Vector Analysis: Sky Lending Target Protocol : Sky Lending (TVL: $5905.6M) Sky Lending – Flash‑Loan Attack Vector Analysis Technical Security & Audit Report Prepared by: [Your Firm…

  • Oracle price manipulation via flash loans poses high-moderate risk to Sky Lending protocol.
  • Re-entrancy in withdrawRewards() callback could drain up to $150 million in reward tokens.
  • Cross-L2 bridge race condition creates ghost liquidity, enabling under-collateralized borrowing.

More from Thursday 8 October →