我正在使用Codeigniter rest服务器和firebase php-jwt创建一个安静的服务。 创建一个api来返回运算符列表。要访问此API,客户端必须在标头中发送令牌。样品申请是 -
GET /index.php/operators/prepaid HTTP / 1.1
主持人:testing.mydomain.in
授权:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjExNTIxNCIsImlhdCI6MTUxNzk4MjU1NywiZXhwIjoxNTE4MDAwNTU3fQ.PZYh3OlSsKGo_ihPPSm7RrU5BbTNaeTN1fKlNcOZ2r4
缓存控制:无缓存
邮差 - 令牌:933f3b1d-7934-d30a-11bf-f80f3912f433
控制器代码
use \Firebase\JWT\JWT;
class Operators extends REST_Controller
{
private $_payload;
public function __construct($config = 'rest')
{
parent::__construct($config);
$token = $this->input->get_request_header('Authorization');
if(!$token) {
$output = array("Error" => "Access Denied");
$this->response($output, REST_Controller::HTTP_UNAUTHORIZED);
}
try {
$this->_payload = JWT::decode($token, $this->config->item('jwt_secret_key'),array('HS256'));
} catch (Exception $ex) {
$output = array("Error" => $ex->getMessage());
$this->response($output, REST_Controller::HTTP_UNAUTHORIZED);
}
$this->load->model('Operators_Data');
}
public function prepaid_get()
{
$operators = $this->Operators_Data->getOperatorsByService(1);
$this->response($operators);
}
}
我得到以下结果
{
"Error": "Access Denied"
}
如果令牌不存在,则从控制器构造函数返回。但是我在标题授权中发送令牌。
这适用于我的本地主机(它返回运算符列表)。但是当我 从测试服务器尝试它总是返回"访问被拒绝"。
更新:非常确定服务器是否忽略"授权"报头中。
还尝试了
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
.htaccess中的设置
非常感谢任何帮助。
答案 0 :(得分:0)
添加
+ geom_smooth(
data = data.frame1,
aes(x = variable1, y = variable2, color = "red"),
method = "lm"
)
=IF(D5="Misc",Jobs!A2,IF(D5=1715,Jobs!A3,IF(D5=1725,Jobs!A4,IF(D5=5640,Jobs!A5,IF(D5=6121,Jobs!A7,IF(D5=6150,Jobs!A8,IF(D5="6161-IDC",Jobs!A10,IF(D5="6161-JM",Jobs!A11,IF(D5=6161,Jobs!A12,IF(D5=6535,Jobs!A14,IF(D5="Hudson",Jobs!A14,IF(D5="Berendo",Jobs!A15,IF(D5="Berendo-Move",Jobs!A16,IF(D5="Bungalos",Jobs!A17,IF(D5="Bungalo",Jobs!A17,IF(D5="Camarillo",Jobs!A18,IF(D5="Indio",Jobs!A19,IF(D5="Lillian",Jobs!A20,IF(D5="6161-Beam",Jobs!A21,IF(D5="6161-Roof",Jobs!A22))))))))))))))))))))
文件顶部的以我的情况解决了该问题