【问题标题】:Bittrex API returns APIKEY_NOT_PROVIDED in PostmanBittrex API 在 Postman 中返回 APIKEY_NOT_PROVIDED
【发布时间】:2020-06-18 02:10:13
【问题描述】:

我正在尝试在 Postman 中使用 Bittrex API,但所有 API 调用都返回“APIKEY_NOT_PROVIDED”。我很确定这是因为 Bittrex 需要 SHA512 HMAC 身份验证,所以有人知道如何克服这个问题吗?有没有可以使用的预请求脚本,甚至可以导入的Postman环境?

币安有一个用于 SHA256 HMAC 身份验证 (https://github.com/binance-exchange/binance-api-postman) 的 Postman 环境,让这一切变得超级简单。

谢谢!

【问题讨论】:

    标签: rest api postman


    【解决方案1】:

    这是我前段时间在 Postman 中用于创建 HMAC-SHA256 签名的一些预请求脚本,它应该让您了解如何专门针对 Binance 请求修改它。

    var ts = Math.round((new Date().getTime()/1000));
    var key = 'YOUR_API_KEY';
    var secret = 'YOUR_API_SECRET';
    
    var createSig = function() {
        var hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, secret);
        hmac.update(ts.toString());
        hmac.update(request.method.toUpperCase());
        hmac.update(request.url);
        hmac.update(request.method === 'GET' ? '' : request.data);
        return hmac.finalize();
    };
    
    postman.setGlobalVariable('ts', ts);
    postman.setGlobalVariable('key', key);
    postman.setGlobalVariable('sig', createSig());
    

    脚本将设置 3 个变量:

    • ts - 当前的 unix 时间戳
    • key - API 密钥
    • sig - HMAC 计算签名

    在 Postman 的请求标头中使用它们,如屏幕截图所示,修改以适应 Binance 请求:

    【讨论】:

      猜你喜欢
      • 2017-11-20
      • 1970-01-01
      • 1970-01-01
      • 2021-10-18
      • 1970-01-01
      • 2018-06-16
      • 1970-01-01
      • 2020-03-17
      • 1970-01-01
      相关资源
      最近更新 更多