我已经为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();
}
}