我正在使用Caspio Bridge数据库(REST API)。我想知道如何在使用AJAX的每个请求中生成访问令牌。要获取访问令牌,我需要:Client_ID
,Client_Secret
,URL_Token
。我有所有这些数据。
jQuery.ajax({
url: 'https://xxxxx.caspio.com/rest/v2/tables/Test_Database_1Million/records',
type: 'POST',
contentType: 'application/json; charset=UTF-8',
'data': JSON.stringify({
"UniqueID": "55",
"Drivers_Full_Name": "My_name"
}),
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "BEARER " + access_token); // how to generate automaticaly??
},
success: function(data) {
console.log(data.Result);
},
error: function(data) {
console.log(data.responseJSON);
}
});