A Visual Studio Code TypeScript project for a SPA application using AdalJS, jQuery, Office365 Graph API and SharePoint Online REST API.
References:
- OfficeDev/O365-jQuery-CORS
- AzureAD/azure-activedirectory-library-for-js
- Authentication Scenarios for Azure AD
- Cloud Identity: Introducing ADAL JS v1
- Cloud Identity: ADAL JavaScript and AngularJS – Deep Dive
- http://blog.wolksoftware.com/setting-up-your-typescript-vs-code-development-environment
- remojansen/ts-vscode-boilerplate
- Calling the Office 365 Unified API from JavaScript using ADAL.js
Getting started is simple! To run this sample you will need:
- Visual Studio Code
- NodeJS
- An Internet connection
- An Azure subscription (a free trial is sufficient)
Every Azure subscription has an associated Azure Active Directory tenant. If you don't already have an Azure subscription, you can get a free subscription by signing up at http://www.windowsazure.com. All of the Azure AD features used by this sample are available free of charge.
git clone https://github.com/phillipharding/O365-ADALJS-TypeScript-jQuery-SPA.git
Note: Before running the following commands, make sure you have Node.js installed and that you have installed typings and gulp as global packages:
$ npm -g install gulp
$ npm -g install typings
For your local dev server you can use either NPM http-server or browser-sync, to use http-server install it globally;
$ npm -g install http-server
$ cd O365-ADALJS-TypeScript-SPA
$ npm install
$ typings install
Follows Steps 2, 3 and 4 from the OfficeDev/O365-jQuery-CORS sample.
Note: The sample is configured to use http://localhost:3000 as the local dev server, so you should use this URL
as the Sign-In URL and Reply URL in your Azure AD Application registration.
- Open the sample in Visual Studio Code
- Open source/main.ts and source/callback.ts files, at the top of each file;
- Replace the value of
TenantName
with your AAD tenant name. - Replace the value of
ClientId
with the Client ID from the Azure Management Portal.
- Replace the value of
-
Use
Command
+P
-
Type task default and press
ENTER
or, at the
Terminal
, type gulp default and pressENTER
-
The sample will build, the test will run and output will display in the Output window
When the sample is run, it will try to Authenticate you straight away.
To use the NPM http-server method;
- Open a Terminal window
- cd O365-ADALJS-TypeScript-SPA
- Type http-server ./ -p 3000 -c-1 and press
ENTER
- Go to your browser and enter http://localhost:3000 into the address bar
To use the NPM browser-sync method;
-
Use
Command
+P
type task serve and pressENTER
or, at the
Terminal
, type gulp serve and pressENTER
-
Your browser should open at the URL http://localhost:3000
Please send a PR! If you know how to make this sample better.