auth = null; $requestHeaders = apache_request_headers(); $requestHeaders = array_combine(array_map('ucwords', array_keys($requestHeaders)), array_values($requestHeaders)); if(isset($requestHeaders['Authorization'])) { $headers = trim($requestHeaders['Authorization']); } if(!empty($headers)) { if(preg_match('/Bearer\s(\S+)/', $headers, $matches)) { $this->auth = $matches[1]; } } return $this->auth; } public function tokenCheck($secret) { $this->token = $this->tokenGet(); $this->response = array(); try { $decoded = JWT::decode($this->token, $secret, array('HS256')); $this->response = array( "status" => 200, "access" => "GRANTED", "token" => $this->token//$decoded ); } catch(Exception $e) { $this->response = array( "status" => 401, "access" => "DENIED", "error" => $e->getMessage() ); } return $this->response; } } ?>