Skip to content

Instantly share code, notes, and snippets.

@andrewconnell
Created March 8, 2015 16:46
Show Gist options
  • Save andrewconnell/a5d19e703cdcd8b58d13 to your computer and use it in GitHub Desktop.
Save andrewconnell/a5d19e703cdcd8b58d13 to your computer and use it in GitHub Desktop.
ADAL JS + Angular: Initializing the ADAL provider
module adalO365CorsClient {
'use strict';
export class Adal {
/**
* Configures ADAL JS with required info for the registered app in Azure AD.
*
* @param $httpProvider Angular's $httpProvider (needed by ADAL)
* @param adalSettings Settings for ADAL
* @param adalProvider ADAL JS' Angular provider.
*/
static configure($httpProvider:ng.IHttpProvider,
adalSettings:shared.IAdalSettings,
adalProvider:any):void {
// init the ADAL service
adalProvider.init({
tenant: '7d8ba536-3406-4865-8884-be9a5b3802ec',
clientId: 'b2bb3c28-a7be-4f3b-a2b5-f11c9d808953',
postLogoutRedirectUri: 'http://localhost:8000',
endpoints: {
/* 'target endpoint to be called': 'target endpoint's resource ID' */
// sharepoint site containing lists
'https://[your-tenant-here].sharepoint.com/_api/': 'https://[your-tenant-here].sharepoint.com',
// o365 files api
'https://[your-tenant-here]-my.sharepoint.com/_api/v1.0/me': 'https://[your-tenant-here]-my.sharepoint.com/'
}
}, $httpProvider);
}
}
}
@w0nderw0man
Copy link

thanks you for your example @andrewconnell 👍
Just for your information you can place the tenant name rather than your tenantId in configuration adalProvider :

tenant: 'nameofyourtenant.com'

And URL is more beautiful for the users during the authentication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment