How to get authentication with jwt slim middleware?(如何使用JWT SLIM中间件进行身份验证?)
问题描述
此代码可以工作,但如何通过GET请求获取查看/api
内容的权限??
<?php
use PsrHttpMessageServerRequestInterface as Request;
use PsrHttpMessageResponseInterface as Response;
require 'vendor/autoload.php';
$app = new SlimApp();
$app->add(new SlimMiddlewareJwtAuthentication([
"path" => "/api",
"secret" => "1234"
]));
$app->get('/api', function (Request $request, Response $response) {
echo "Hi";
});
$app->get('/teste', function (Request $request, Response $response) {
echo "Hi";
});
$app->run();
推荐答案
我用的是Authorization: Bearer Mykey
,密钥需要在jwt模式下编码
这篇关于如何使用JWT SLIM中间件进行身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!