Mixpanel - 验证问题,javascript
Mixpanel - authenticate issue, javescript
我尝试将 'Export Raw Data' 端点与“https://data.mixpanel.com/api/2.0/export/”
一起使用
但注意是工作...
我尝试了很多请求和自由 - 导出端点没有任何作用
我的代码:
$.ajaxPrefilter( function (options) {
if (options.crossDomain && jQuery.support.cors) {
var http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
options.url = http + '//cors.now.sh/' + options.url;
}
});
mixpanel_base_uri = "https://data.mixpanel.com/api/2.0" ;
proxy = "" // "https://cors-anywhere.herokuapp.com/"
var ajaxRequest = $.ajax({
url : "" + mixpanel_base_uri + "/" + end_point + "/?",
data: args,
dataType: "text",
processData: true,
headers:{
// "Access-Control-Allow-Credentials" : true,
// "Access-Control-Allow-Methods": "GET, OPTIONS",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*"
// ('Authorization', 'Basic ' + btoa(api_secret+ ':' +'')),
},
xhrFields: {
// Getting on progress streaming response
withCredentials: true,
onprogress: function(e)
{
console.log(e)
// var progressResponse;
// var response = e.currentTarget.response;
// if(lastResponseLength === false)
// {
// progressResponse = response;
// lastResponseLength = response.length;
// }
// else
// {
// progressResponse = response.substring(lastResponseLength);
// lastResponseLength = response.length;
// }
// console.log(response)
}
}
});
// On completed
ajaxRequest.done(function(data) {
console.log('Complete response = ' + data);
});
// On failed
ajaxRequest.fail(function(error){
console.log('Error: ', error);
});
我尝试使用 'node-mixpanel-export.js' 和 'mixpanel-data-export' 自由主义者,但它们不起作用
我遇到很多错误(每次都不同)
来自:
Access to XMLHttpRequest at 'https://data.mixpanel.com/api/2.0/export/?&from_date=01-08-2019&to_date=01-09-2019'
from origin 'http://localhost:8888' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
mixpanel_connector.js:129
和:
To authenticate your request, you must use your API Secret in the HTTP authorization header
我添加身份验证时的事件仍然无法正常工作。
如果有人可以帮助我?或者有我能理解的有效代码
谢谢。
------更新------
我解决了几乎所有的问题,但我无法通过授权问题,什么都不管用..也许我错过了什么?
var obj = new XMLHttpRequest();
var params = JSON.stringify(args);
obj.onreadystatechange = function() {
if (obj.readyState == 4 && obj.status == "200"){
console.log(obj)
doneCallback();
}
}
obj.open("GET",mixpanel_base_uri + end_point);
obj.setRequestHeader('Authorization', 'Basic ' + base64Encode(this.api_secret + ':'));
obj.setRequestHeader("Content-type", "application/json; charset=utf-8");
obj.send(params);
我设置的授权与 Mixplane 公会完全一样:
但仍然出现同样的错误:
To authenticate your request, you must use your API Secret in the HTTP authorization header
授权问题。
通过混合面板:
To make an authorized request, put your project's API Secret in the "username" field of the Basic access authentication header. Make sure you use HTTPS and not HTTP - as our API rejects requests made over HTTP. Sending over HTTP can expose your API Secret.
Client Libraries
问题是 javascript 中的 "bota" 函数不是 return 正确的哈希
只需将其更改为其他哈希函数
我尝试将 'Export Raw Data' 端点与“https://data.mixpanel.com/api/2.0/export/”
一起使用但注意是工作... 我尝试了很多请求和自由 - 导出端点没有任何作用
我的代码:
$.ajaxPrefilter( function (options) {
if (options.crossDomain && jQuery.support.cors) {
var http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
options.url = http + '//cors.now.sh/' + options.url;
}
});
mixpanel_base_uri = "https://data.mixpanel.com/api/2.0" ;
proxy = "" // "https://cors-anywhere.herokuapp.com/"
var ajaxRequest = $.ajax({
url : "" + mixpanel_base_uri + "/" + end_point + "/?",
data: args,
dataType: "text",
processData: true,
headers:{
// "Access-Control-Allow-Credentials" : true,
// "Access-Control-Allow-Methods": "GET, OPTIONS",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*"
// ('Authorization', 'Basic ' + btoa(api_secret+ ':' +'')),
},
xhrFields: {
// Getting on progress streaming response
withCredentials: true,
onprogress: function(e)
{
console.log(e)
// var progressResponse;
// var response = e.currentTarget.response;
// if(lastResponseLength === false)
// {
// progressResponse = response;
// lastResponseLength = response.length;
// }
// else
// {
// progressResponse = response.substring(lastResponseLength);
// lastResponseLength = response.length;
// }
// console.log(response)
}
}
});
// On completed
ajaxRequest.done(function(data) {
console.log('Complete response = ' + data);
});
// On failed
ajaxRequest.fail(function(error){
console.log('Error: ', error);
});
我尝试使用 'node-mixpanel-export.js' 和 'mixpanel-data-export' 自由主义者,但它们不起作用
我遇到很多错误(每次都不同) 来自:
Access to XMLHttpRequest at 'https://data.mixpanel.com/api/2.0/export/?&from_date=01-08-2019&to_date=01-09-2019'
from origin 'http://localhost:8888' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
mixpanel_connector.js:129
和:
To authenticate your request, you must use your API Secret in the HTTP authorization header
我添加身份验证时的事件仍然无法正常工作。
如果有人可以帮助我?或者有我能理解的有效代码
谢谢。
------更新------
我解决了几乎所有的问题,但我无法通过授权问题,什么都不管用..也许我错过了什么?
var obj = new XMLHttpRequest();
var params = JSON.stringify(args);
obj.onreadystatechange = function() {
if (obj.readyState == 4 && obj.status == "200"){
console.log(obj)
doneCallback();
}
}
obj.open("GET",mixpanel_base_uri + end_point);
obj.setRequestHeader('Authorization', 'Basic ' + base64Encode(this.api_secret + ':'));
obj.setRequestHeader("Content-type", "application/json; charset=utf-8");
obj.send(params);
我设置的授权与 Mixplane 公会完全一样:
但仍然出现同样的错误:
To authenticate your request, you must use your API Secret in the HTTP authorization header
授权问题。
通过混合面板:
To make an authorized request, put your project's API Secret in the "username" field of the Basic access authentication header. Make sure you use HTTPS and not HTTP - as our API rejects requests made over HTTP. Sending over HTTP can expose your API Secret.
Client Libraries
问题是 javascript 中的 "bota" 函数不是 return 正确的哈希 只需将其更改为其他哈希函数