<?php /** * SIMPLE JWT TOKEN GENERATOR FOR C# API GATEWAY * * Quick setup: * 1. Run: composer install * 2. Update the $clientSecret variable below * 3. Run: php simple_jwt_example.php */ require_once 'vendor/autoload.php'; // ======================================== // CONFIGURATION (Match your Program.cs) // ======================================== $issuer = "https://abc.com/authservice"; $audience = "https://abc.com/megamart"; $clientSecret = "YOUR_SECRET_KEY_HERE"; // ⚠️ MUST MATCH Line 5 in Program.cs! // ======================================== // CREATE TOKEN // ======================================== $payload = [ 'iss' => $issuer, // Issuer 'aud' => $audience, // Audience 'iat' => time(), // Issued at 'nbf' => time(), // Not before 'exp' => time() + (60 * 60), // Expires in 1 hour // Custom claims (your user data) 'sub' => '12345', // User ID 'name' => 'John Doe', 'email' => 'john.doe@example.com', 'role' => 'Admin' ]; $jwt = JWT::encode($payload, $clientSecret, 'HS256'); // ======================================== // OUTPUT // ======================================== echo "JWT Token Generated:\n"; echo "====================\n\n"; echo $jwt . "\n\n"; ?> <?php /** * SIMPLE JWT TOKEN GENERATOR FOR C# API GATEWAY * * Quick setup: * 1. Run: composer install * 2. Update the $clientSecret variable below * 3. Run: php simple_jwt_example.php */ require_once 'vendor/autoload.php'; use Firebase\JWT\JWT; // ======================================== // CONFIGURATION (Match your Program.cs) // ======================================== $issuer = "https://abc.com/authservice"; $audience = "https://abc.com/megamart"; $clientSecret = "YOUR_SECRET_KEY_HERE"; // ⚠️ MUST MATCH Line 5 in Program.cs! // ======================================== // CREATE TOKEN // ======================================== $payload = [ 'iss' => $issuer, // Issuer 'aud' => $audience, // Audience 'iat' => time(), // Issued at 'nbf' => time(), // Not before 'exp' => time() + (60 * 60), // Expires in 1 hour // Custom claims (your user data) 'sub' => '12345', // User ID 'name' => 'John Doe', 'email' => 'john.doe@example.com', 'role' => 'Admin' ]; $jwt = JWT::encode($payload, $clientSecret, 'HS256'); // ======================================== // OUTPUT // ======================================== echo "JWT Token Generated:\n"; echo "====================\n\n"; echo $jwt . "\n\n"; ?>
You have javascript disabled. You will not be able to edit any code.