• <legend id='LfrBH'><style id='LfrBH'><dir id='LfrBH'><q id='LfrBH'></q></dir></style></legend>

    • <bdo id='LfrBH'></bdo><ul id='LfrBH'></ul>
    <tfoot id='LfrBH'></tfoot>

    1. <i id='LfrBH'><tr id='LfrBH'><dt id='LfrBH'><q id='LfrBH'><span id='LfrBH'><b id='LfrBH'><form id='LfrBH'><ins id='LfrBH'></ins><ul id='LfrBH'></ul><sub id='LfrBH'></sub></form><legend id='LfrBH'></legend><bdo id='LfrBH'><pre id='LfrBH'><center id='LfrBH'></center></pre></bdo></b><th id='LfrBH'></th></span></q></dt></tr></i><div id='LfrBH'><tfoot id='LfrBH'></tfoot><dl id='LfrBH'><fieldset id='LfrBH'></fieldset></dl></div>

      <small id='LfrBH'></small><noframes id='LfrBH'>

        带有标头的基本身份验证 - Javascript XMLHttpRequest

        时间:2023-10-14
      1. <tfoot id='fZbOI'></tfoot>

            <tbody id='fZbOI'></tbody>
        • <i id='fZbOI'><tr id='fZbOI'><dt id='fZbOI'><q id='fZbOI'><span id='fZbOI'><b id='fZbOI'><form id='fZbOI'><ins id='fZbOI'></ins><ul id='fZbOI'></ul><sub id='fZbOI'></sub></form><legend id='fZbOI'></legend><bdo id='fZbOI'><pre id='fZbOI'><center id='fZbOI'></center></pre></bdo></b><th id='fZbOI'></th></span></q></dt></tr></i><div id='fZbOI'><tfoot id='fZbOI'></tfoot><dl id='fZbOI'><fieldset id='fZbOI'></fieldset></dl></div>

          <legend id='fZbOI'><style id='fZbOI'><dir id='fZbOI'><q id='fZbOI'></q></dir></style></legend>
        • <small id='fZbOI'></small><noframes id='fZbOI'>

            <bdo id='fZbOI'></bdo><ul id='fZbOI'></ul>

                  本文介绍了带有标头的基本身份验证 - Javascript XMLHttpRequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试访问需要基本身份验证凭据的 Adyen 测试 API.

                  但我在尝试使用 XMLHttpRequest POST 请求访问 API 时收到 401 Unauthorized 响应.

                  Javascript 代码

                  var url = "https://pal-test.adyen.com/pal/servlet/Payment/v25/authorise";var username = "ws@Company.CompanyName";var 密码 = "J}5fJ6+?e6&lh/Zb0>r5y2W5t";var base64Credentials = btoa(用户名+":"+密码);var xhttp = new XMLHttpRequest();xhttp.open("POST", url, true);xhttp.setRequestHeader("内容类型", "应用程序/json");xhttp.setRequestHeader("授权", "基本" + base64Credentials);var requestParams = XXXXXXXX;xhttp.send(requestParams);


                  结果

                  解决方案

                  PAL 是一个支付授权 API.您从不想从浏览器调用它.您只想公开您的用户名和密码,以便在您的后端代码中发送付款.

                  在客户端加密中,加密是在浏览器中完成的.然后,您将加密数据发送到您自己的服务器.然后在您的服务器上创建一个支付授权请求(其中加密数据是元素之一,以及支付金额等).

                  如果您能够设法从浏览器运行此操作,您的最终解决方案将允许您的购物者从 JavaScript 层更改金额、货币、支付元数据等.绝不应该是这种情况.

                  因此,授权是文档服务器端"集成部分的一部分:https://docs.adyen.com/developers/ecommerce-integration?ecommerce=ecommerce-integration#serverside

                  根据您的服务器端环境,您最喜欢的语言的 CURL 实现会有所不同,但大多数时候很容易找到.

                  亲切的问候,

                  阿诺德

                  I am trying to access Adyen test API that requires basic authentication credentials. https://docs.adyen.com/developers/ecommerce-integration

                  My credentials work when accessing the API page through browser.

                  But I get an 401 Unauthorized response when trying to access the API with XMLHttpRequest POST request.

                  Javascript Code

                  var url = "https://pal-test.adyen.com/pal/servlet/Payment/v25/authorise";
                  
                  var username = "ws@Company.CompanyName";
                  var password = "J}5fJ6+?e6&lh/Zb0>r5y2W5t";
                  var base64Credentials = btoa(username+":"+password);
                  
                  var xhttp = new XMLHttpRequest();
                  xhttp.open("POST", url, true);
                  xhttp.setRequestHeader("content-type", "application/json");
                  xhttp.setRequestHeader("Authorization", "Basic " + base64Credentials);
                  
                  var requestParams = XXXXXXXX;
                  xhttp.send(requestParams);
                  


                  Result

                  解决方案

                  The PAL is a Payment Authorisation API. You never want to call it from a browser. You only want to expose your username and password to send in payments in your backend code.

                  In Client-side encryption, the encryption is done in the browser. You then send the encrypted data to your own server. On your server you then create a payment authorization request (of which the encrypted data is one of the elements, along side payment amount, etc).

                  If you would be able to manage to make this run from your browser, your end solution will allow your shoppers to change amounts, currency's, payment meta data etc from the JavaScript layer. This should never be the case.

                  The authorization is for that reason part of the "Server side" integration part of documentation: https://docs.adyen.com/developers/ecommerce-integration?ecommerce=ecommerce-integration#serverside

                  Depending on your server side landscape the CURL implementation in your favorite language differs, but most of the time are easy to find.

                  Kind regards,

                  Arnoud

                  这篇关于带有标头的基本身份验证 - Javascript XMLHttpRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:xhr 发送 base64 字符串并在服务器中将其解码为文 下一篇:如何处理对后端服务进行相同调用的多个浏览器

                  相关文章

                  最新文章

                  <i id='oeF0t'><tr id='oeF0t'><dt id='oeF0t'><q id='oeF0t'><span id='oeF0t'><b id='oeF0t'><form id='oeF0t'><ins id='oeF0t'></ins><ul id='oeF0t'></ul><sub id='oeF0t'></sub></form><legend id='oeF0t'></legend><bdo id='oeF0t'><pre id='oeF0t'><center id='oeF0t'></center></pre></bdo></b><th id='oeF0t'></th></span></q></dt></tr></i><div id='oeF0t'><tfoot id='oeF0t'></tfoot><dl id='oeF0t'><fieldset id='oeF0t'></fieldset></dl></div>
                    <bdo id='oeF0t'></bdo><ul id='oeF0t'></ul>
                • <small id='oeF0t'></small><noframes id='oeF0t'>

                  1. <tfoot id='oeF0t'></tfoot>
                    <legend id='oeF0t'><style id='oeF0t'><dir id='oeF0t'><q id='oeF0t'></q></dir></style></legend>