【问题标题】:slim Authorization is not working after a whileslim 授权在一段时间后不起作用
【发布时间】:2016-11-08 07:49:47
【问题描述】:

我已经为我的应用程序实现了一个苗条的 api,它在标题中获得一个 api_key 得到有效的请求 这是代码

function authenticate(\Slim\Route $route) {
// Getting request headers
$headers = apache_request_headers();
$response = array();
$app = \Slim\Slim::getInstance();

// Verifying Authorization Header
if (isset($headers['Authorization'])) {
    $db = new DbHandler();
     global $api_key;
    // get the api key
    $api_key = $headers['Authorization'];
    // validating api key
    if (!$db->isValidApiKey($api_key)) {
        // api key is not present in users table
        $response["error"] = true;
        $response["message"] = "Access Denied. Invalid Api key";
        echoRespnse(401, $response);
        $app->stop();
    } else {
        global $user_id;
        // get user primary key id
        $user_id = $db->getUserId($api_key);
    }
} else {
    // api key is missing in header
    $response["error"] = true;
    $response["message"] = "Api key is misssing";
    echoRespnse(400, $response);
    $app->stop();
}

} 它工作正常,但突然我的代码没有任何变化,我得到了 apikey 虽然我现在在标题中添加授权,如果我将授权更改为 Authorizationn 或其他一些东西,它会再次工作但我担心一段时间后我得到新地址再次出现 smae 错误。现在的问题是主机头中的一个特定地址是否有任何限制,或者任何人都知道它为什么会发生

【问题讨论】:

  • 你用什么来测试你的请求?
  • google chroom 上的邮递员和我在 android 中的应用程序都给我 api 密钥丢失!

标签: php slim


【解决方案1】:

确保您的授权具有您的 API 密钥的值。

【讨论】:

  • tanx 亲爱的,我的授权具有 api key 的值 :(
  • 确保在您的邮递员授权中以大写 A 开头,而不是小写 a
  • 我已经检查了所有这些实际上它刚刚开始敬酒 api key is missing without any change in my code
猜你喜欢
  • 2015-05-03
  • 2021-08-22
  • 1970-01-01
  • 1970-01-01
  • 2012-04-24
  • 2015-08-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多