0
我想從我的Outlook日曆中進行身份驗證並獲取事件。 能夠登錄和驗證用戶,但是當我嘗試獲取事件時,我正在獲取跨源問題。調用獲取Outlook日曆事件api時不允許控制 - 允許 - 起源問題
這裏是我的代碼片段:
<button id="SignIn" onclick="signIn()">Sign In</button>
<h4 id="WelcomeMessage"></h4>
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.12/js/adal.min.js"></script>
<script>
var ADAL = new AuthenticationContext({
instance: 'https://login.microsoftonline.com/',
tenant: 'common', //COMMON OR YOUR TENANT ID
clientId: '<its my client id>', //This is your client ID
redirectUri: 'http://localhost:8000', //This is your redirect URI
callback: userSignedIn,
popUp: true
});
\t window.authContext = new AuthenticationContext(ADAL);
var isCallback = authContext.isCallback(window.location.hash);
authContext.handleWindowCallback();
function signIn() {
ADAL.login();
}
function userSignedIn(err, token) {
console.log('userSignedIn called');
if (!err) {
console.log("token: " + token);
showWelcomeMessage();
}
else {
console.error("error: " + err);
}
}
function showWelcomeMessage() {
var user = ADAL.getCachedUser();
var divWelcome = document.getElementById('WelcomeMessage');
divWelcome.innerHTML = "Welcome " + user.profile.name;
\t loadEvents();
}
function loadEvents() {
console.log("in load events");
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://outlook.office.com/api/v2.0/me/calendarview?startDateTime=2016-10-01T01:00:00&endDateTime=2016-10-31T23:00:00&$select=Subject", true);
xhr.send();}
</script>
在結束運行腳本這是我的錯誤後。
任何幫助表示讚賞。 謝謝
是否有原因導致您使用https://outlook.office.com而不是https://outlook.office365.com? –