Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php check jwt token expired

$jwt = getBearerToken();

try {

$decoded = JWT::decode($jwt, $key, array('HS256'));
$refresh_token=$decoded->data->refresh_token;

}

catch (Exception $e){

if($e->getMessage() == "Expired token"){
    list($header, $payload, $signature) = explode(".", $jwt);
    $payload = json_decode(base64_decode($payload));
    $refresh_token = $payload->data->refresh_token;

} else {

    // set response code
    http_response_code(401);

    // show error message
    echo json_encode(array(
        "message" => "Access denied.",
        "error" => $e->getMessage()
    ));
    die();
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: execute script php command line 
Php :: checks if file is empty in php 
Php :: determine if file is empty in php 
Php :: creating default object from empty value laravel 
Php :: php send post request 
Php :: where is in array laravel 
Php :: how to get stripe processing fees api 
Php :: laravel merge two arrays helper 
Php :: how to get length array in php 
Php :: laravel factory pass parameter 
Php :: PHP - AJAX and PHP 
Php :: error laravel 404 in server 
Php :: transient wp 
Php :: laravel composer sanctum 
Php :: laravel one to many relationship 
Php :: How to Get Radio Button Value in PHP Without Submit 
Php :: drupal 8 entity_view 
Php :: laravel download file change name 
Php :: match uuid patter laravel regex 
Php :: Regex to remove span tags using php [duplicate] 
Php :: array in php 
Php :: guarded and fillable in laravel 
Php :: php print string as bytes 
Php :: extract in php 
Php :: nginx php-fpm 
Php :: laravel get data from model to controller 
Php :: change sender name laravel 
Php :: wordpress change email new user template 
Php :: laravel allow all fillable 
Php :: laravel query when 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =