【问题标题】:javascript authenticate with htpasswd and fetch jsonjavascript 使用 htpasswd 进行身份验证并获取 json
【发布时间】:2016-07-19 12:17:09
【问题描述】:

我有一个生成 json 的 API,问题是它的密码保护 url,使用 Apache htpasswd。

我如何从 javascript 验证和检索 json,因为我尝试过的所有方法都允许我访问定义(我一直在使用 http://username:passwd@urldotcom/path/to/stuff

谢谢

【问题讨论】:

    标签: javascript .htpasswd


    【解决方案1】:

    我想出了办法。

     var something = jQuery.ajax({
        type: "GET",
        url: url,
        username: "user",
        password: "password"    
    });
    

    url 是我之前声明的一个变量,格式为 http:///path/to/json

    【讨论】:

    • 您认为这种技术或类似的技术可以访问受 htpasswd 保护的文件吗?我已经问了here的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-08
    相关资源
    最近更新 更多