JavaScript pCloud API 调用获取用户信息时出错

JavaScript pCloud API call to fetch userinfo gives an error

同时从 JavaScript

调用 api

这个 HTTP 请求工作正常https://api.pcloud.com/userinfo?username=xxxx@gmail.com&password=xxxx

在下面的代码中,我想通过 JavaScript

调用
var user='email loggin';
var password='password of pcloud';

function make_base_auth(user, password) {
  var tok = user + ':' + password;
  var hash = btoa(tok);
  return "Basic " + hash;
}

$.ajax
  ({
    type: "GET",
    url: "https://api.pcloud.com/userinfo",
    dataType: 'json',
    async: false,
    data: '{}',
    beforeSend: function (xhr){ 
        xhr.setRequestHeader('Authorization', make_base_auth(username, password)); 
    },
    success: function (){
        alert('Working Fine'); 
    }
});

控制台输出

XMLHttpRequest cannot load https://api.pcloud.com/userinfo?{}. Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.

如果有人可以提供解决方案或增强代码。

data 字段中传递用户名和密码并删除 "beforeSend" 部分。有关更多信息和示例,您可以查看 pCloud Javascript SDK:https://github.com/pCloud/pcloud-sdk-js

这是工作示例(稍微短一点):

$.getJSON("https://api.pcloud.com/userinfo", {
  username: "***", 
  password: "***"
}, function() {
  alert("working fine"); 
});