Skip to content

Commit 656abe6

Browse files
authored
Create decode-header.php
1 parent 2e542a5 commit 656abe6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

decode-header.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
// https://github.com/BaseMax/php-jwt-example
3+
require 'vendor/autoload.php';
4+
use \Firebase\JWT\JWT;
5+
use \Firebase\JWT\SignatureInvalidException;
6+
$key = '83aeee518617ad6f3393bf0685e37d3e';
7+
8+
$headers=getallheaders();
9+
// LOG: print_r($headers);
10+
if(!isset($headers["Authorization"])) {
11+
exit("No 'Authorization' header!\n");
12+
}
13+
14+
$token = $headers["Authorization"];
15+
$token = str_replace("Bearer ", "", $token); // or remove 'Bearer ' from first of letters!
16+
17+
$decode = JWT::decode($jwt, $key, array('HS256'));
18+
print $decode;

0 commit comments

Comments
 (0)