當我嘗試通過使用其他端口的另一個站點使用Google Calendar API時,我收到錯誤origin_mismatch消息。錯誤:使用Google日曆API和端口444時的origin_mismatch
當從http://original.domain.edu發送API請求時,代碼不會返回錯誤。
但是,當代碼從https://original.domain.edu:444(這是應用程序使用的安全登錄端口)發送API請求時,代碼會返回上述標題錯誤。
我在我的API控制檯中向我的OAuth客戶端添加了https://original.domain.edu:444和https://original.domain.edu,但同樣的錯誤仍在發生。有人可以提供一些幫助嗎?
var exportCalendarToGoogle = function() {
var clientId = 'XXXXXXXXXXXXXXXXXXXXXXXXX';
var scope = 'https://www.googleapis.com/auth/calendar';
var apiKey = 'XXXXXXXXXXXXXXXXXXXXXXXXX';
var withGApi = function() {
console.log("gapi loaded");
setTimeout(function() {
gapi.client.setApiKey(apiKey);
gapi.auth.init(checkAuth);
}, 500);
}
var checkAuth = function() {
gapi.auth.authorize({client_id: clientId, scope: scope, immediate: false}, handleAuthResult);
}
var handleAuthResult = function(authResult) {
if(authResult) {
gapi.client.load("calendar", "v3", exportCalendar);
} else {
alert("Authentication failed: please enter correct login information.");
}
}
...
你的來歷不匹配。一個允許的來源將會與另一個不同的方案(http與https)和/或端口(80 vs 444)不匹配,請按照使用的原則準確添加您的允許來源。 – soulseekah