我已經爲Word創建了Office Addin。當我嘗試對Office 365進行身份驗證時,我正在使用「Office.context.ui.displayDialogAsync」打開一個對話框。我的回調是成功的,對話框打開。對話框打開後,api調用'_dlg.addEventHandler(Office.EventType.DialogEventReceived,processMessage);'它返回錯誤代碼'12003',這意味着需要https,但我的頁面通過https提供。通過對話框從Office Addin對Office 365進行身份驗證
不知道爲什麼我得到這個錯誤,如果我的網頁通過https服務?
$scope.startLogin = function() {
showLoginPopup("/Auth.html").then(function successCallback(response) {
// authentication has succeeded but to get the authenication context for the
// user which is stored in localStorage we need to reload the page.
window.location.reload();
}, function errorCallback(response) {
console.log(response);
});
};
var _dlg;
var _dlgDefer;
var showLoginPopup = function (url) {
_dlgDefer = $q.defer();
Office.context.ui.displayDialogAsync('https://' + location.hostname + url, { height: 40, width: 40}, function (result) {
console.log("dialog has initialized. wiring up events");
_dlg = result.value;
console.log(result.value)
_dlg.addEventHandler(Office.EventType.DialogEventReceived, processMessage);
});
return _dlgDefer.promise;
}
function processMessage(arg) {
console.log(arg.error)
var msg = arg.message;
console.log("Message received in processMessage");
if (msg && msg === "success") {
//we now have a valid auth token in the localStorage
_dlg.close();
_dlgDefer.resolve();
} else {
//something went wrong with authentication
_dlg.close();
console.log("Authentication failed: " + arg.message);
_dlgDefer.reject();
}
}