Skip to content

Instantly share code, notes, and snippets.

@jlemoo
Created September 28, 2015 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlemoo/e7031f50aadc60d90bf0 to your computer and use it in GitHub Desktop.
Save jlemoo/e7031f50aadc60d90bf0 to your computer and use it in GitHub Desktop.
O365 CORS error when accessing SharePoint List (are the SharePoint endpoints correct?)
(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/',
//mail
'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