auth_token_generator

Creator: coderz1093

Last updated:

0 purchases

auth_token_generator Image
auth_token_generator Images

Languages

Categories

Add to Cart

Description:

auth token generator

Auth Token Generator #
Auth Token Generator is a Dart package for generating and validating bearer tokens.
Installation #
To use this package, add auth_token_generator as a dependency in your pubspec.yaml file:
dependencies:
auth_token_generator: ^1.0.0
copied to clipboard
Then, import the package in your Dart code:
dartCopy code
import 'package:auth_token_generator/auth_token_generator.dart';
Usage #
Generating Bearer Tokens #
You can generate bearer tokens using the generateBearerToken method:
final secretKey = 'my_secret_key';
final userId = 'user123';
final token = AuthTokenGenerator.generateBearerToken(secretKey, userId: userId);
print('Generated token: $token');`
copied to clipboard
Extracting User ID from Bearer Tokens #
You can extract the user ID from a bearer token using the getUserIdFromBearerToken method:
final extractedUserId = AuthTokenGenerator.getUserIdFromBearerToken(secretKey, token);
if (extractedUserId != null) {
print('Extracted user ID: $extractedUserId');
} else {
print('Invalid token or signature.');
}
copied to clipboard
License #
This project is licensed under the MIT License - see the LICENSE file for details.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.