Skip to content

Instantly share code, notes, and snippets.

View neparij's full-sized avatar

Nikolay Laptev neparij

  • Yerevan, Armenia
  • 04:48 (UTC +04:00)
View GitHub Profile
@starkdmi
starkdmi / firebase_verify_jwt.dart
Last active September 5, 2024 03:48
Verify JWT token of authenticated Firebase user
import 'package:dio/dio.dart'; // default `http` package can be used as well
import 'package:jose/jose.dart'; // BSD-3-Clause, use `dart_jsonwebtoken` package in case of MIT license
const firebaseProjectId = "FIREBASE_PROJECT_ID";
Map<String, String> googleSecureTokens = {}; // { "KeyId": "PublicKey" } from public Google website
DateTime? googleTokensExpirationDate;
// Verify Firebase JWT token
// https://firebase.google.com/docs/auth/admin/verify-id-tokens#verify_id_tokens_using_a_third-party_jwt_library
Future<bool> validateToken(String token) async {