Skip to content

Package to verify a firebase jwt token by a specific project id

License

Notifications You must be signed in to change notification settings

enzo-desimone/firebase_verify_token_dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Firebase Verify Token

A plugin that allows you to verify a Firebase JWT Token across multiple Firebase projects.

Pub Version Pub Likes Pub Likes Pub Likes GitHub license

Platform Support

Android iOS MacOS Web Linux Windows
✔️ ✔️ ✔️ ✔️ ✔️ ✔️

About

Token verification involves the following steps:

  • Check if the token was generated by one of the specified project IDS.
  • Check if the token was generated by firebase authentication.
  • Check if the token has expired

Install

Import the Check App Version package

To use the Firebase Verify Token package, follow the plugin installation instructions.

Use the package

Add the following import to your Dart code:

import 'package:firebase_verify_token/firebase_verify_token.dart';

Now we need to initialize the static variable projectId in the FirebaseVerifyToken class. You need to enter the firebase project ID.

FirebaseVerifyToken.projectIds = ['project-id-1', 'project-id-2'];

At this point, we can call the verify method from the FirebaseVerifyToken class, passing the string token that we want to verify, as a parameter. The method will return TRUE if the token is valid, FALSE if it is not.

Additionally, you can use the optional onVerifySuccessful callback to execute custom logic when the token is successfully verified.

await FirebaseVerifyToken.verify(
  'my-token-string',
  onVerifySuccessful: ({required bool status, String? projectId}) {
    if (status) {
      print('Token verified for project: $projectId');
    } else {
      print('Token verification failed');
    }
  },
);

About

Package to verify a firebase jwt token by a specific project id

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages