Created
September 28, 2015 21:17
-
-
Save jlemoo/e7031f50aadc60d90bf0 to your computer and use it in GitHub Desktop.
O365 CORS error when accessing SharePoint List (are the SharePoint endpoints correct?)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
angular.module('app', [ | |
'ngRoute', | |
'AdalAngular' | |
]) | |
.config(config); | |
// Configure the routes. | |
function config($routeProvider, $httpProvider, adalAuthenticationServiceProvider) { | |
$routeProvider | |
.when('/', { | |
templateUrl: 'views/home.html', | |
controller: 'HomeController', | |
controllerAs: 'home', | |
requireADLogin: true | |
}) | |
.when('/SharePointDemo', { | |
templateUrl: 'views/SharePoint.html', | |
controller: 'SharePointController', | |
controllerAs: 'sharePoint', | |
requireADLogin: true | |
}) | |
.otherwise({ | |
redirectTo: '/' | |
}); | |
// The endpoints here are resources for cross origin requests. | |
var endpoints = { | |
/* 'target endpoint to be called': 'target endpoint's resource ID' */ | |
// sharepoint site containing lists | |
'https://nysemail.sharepoint.com/_api/': 'https://nysemail.sharepoint.com', | |
'https://nysemail.sharepoint.com/sites/healthapplications/news/_api/': 'https://nysemail.sharepoint.com/sites/healthapplications/news/', | |
// o365 files api | |
'https://nysemail-my.sharepoint.com/_api/v1.0/me': 'https://nysemail-my.sharepoint.com/', | |
'https://outlook.office365.com': 'https://outlook.office365.com' | |
}; | |
// Initialize the ADAL provider with your tenant name and clientID (found in the Azure Management Portal). | |
adalAuthenticationServiceProvider.init( | |
{ | |
tenant: 'nysemail.onmicrosoft.com', | |
clientId: 'c0c98eed-4729-4a08-9300-962c8d1974ea', | |
endpoints: endpoints, | |
cacheLocation: 'localStorage' | |
}, | |
$httpProvider | |
); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment