diff --git a/devApps/VanillaJSTestApp-b2c/Readme.txt b/devApps/VanillaJSTestApp-b2c/Readme.txt new file mode 100644 index 0000000000..2c127b497b --- /dev/null +++ b/devApps/VanillaJSTestApp-b2c/Readme.txt @@ -0,0 +1,28 @@ +What is this sample? +-------------------- +This is a simple JavaScript Simple page application +showcasing how to use MSAL.js to authenticate users +via Azure Active Directory B2C, +and access a Web API with the resulting tokens. + + +How to run this AzureAD B2C sample +---------------------------------- +Pre-requisite +- Install node.js if needed (https://nodejs.org/en/) + +Resolving the server.js references +- In a command prompt, run npm install + +Running the sample +- In a command prompt, run “node server.js” + +- Navigate to http://localhost:6420 with the browser of your choice + +- In the web page, click on the “Login” button +- Sign-up with a local account (at the bottom of the page click sign-up, and then answer the questions) + alternatively sign-in with a gmail account +- Once signed-in, the "Logout" button appears +- Click on "Call Web Api" to call the Web APi application (which source code is in https://github.com/Azure-Samples/active-directory-b2c-javascript-nodejs-webapi) + + Signing-in with an MSA or a Twitter account does not work yet. \ No newline at end of file diff --git a/devApps/VanillaJSTestApp-b2c/index.html b/devApps/VanillaJSTestApp-b2c/index.html new file mode 100644 index 0000000000..f6325d570f --- /dev/null +++ b/devApps/VanillaJSTestApp-b2c/index.html @@ -0,0 +1,119 @@ + + + Calling a Web API as a user authenticated with Msal.js app + + + + + + + + +

Getting an access token with Azure AD B2C and calling a Web API

+
+
Sign-in with Microsoft Azure AD B2C
+ + +
+ +

+
+    
+
+    
+
+
diff --git a/devApps/VanillaJSTestApp-b2c/package.json b/devApps/VanillaJSTestApp-b2c/package.json
new file mode 100644
index 0000000000..8a0fbbbaa5
--- /dev/null
+++ b/devApps/VanillaJSTestApp-b2c/package.json
@@ -0,0 +1,11 @@
+{
+  "name": "msal-js-devapp-b2c",
+  "version": "1.1.0",
+  "license": "MIT",
+  "main": "server.js",
+  "dependencies": {
+    "express": "^4.12.3",
+    "morgan": "^1.5.2",
+    "path": "^0.11.14"
+  }
+}
diff --git a/devApps/VanillaJSTestApp-b2c/server.js b/devApps/VanillaJSTestApp-b2c/server.js
new file mode 100644
index 0000000000..3aed883204
--- /dev/null
+++ b/devApps/VanillaJSTestApp-b2c/server.js
@@ -0,0 +1,29 @@
+/*
+*  Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.
+*  See LICENSE in the source repository root for complete license information.
+*/
+
+var express = require('express');
+var app = express();
+var morgan = require('morgan');
+var path = require('path');
+
+// Initialize variables.
+var port = 6420; // process.env.PORT || 8080;
+
+// Configure morgan module to log all requests.
+app.use(morgan('dev'));
+
+// Set the front-end folder to serve public assets.
+console.log(path.join(__dirname, '../../out'));
+app.use("/out", express.static(path.join(__dirname, "../../out")));
+app.use("/bower_components", express.static(path.join(__dirname, 'bower_components')));
+
+// Set up our one route to the index.html file.
+app.get('*', function (req, res) {
+    res.sendFile(path.join(__dirname + '/index.html'));
+});
+
+// Start the server.
+app.listen(port);
+console.log('Listening on port ' + port + '...'); 
\ No newline at end of file
diff --git a/devApps/VanillaJSTestApp/Readme.txt b/devApps/VanillaJSTestApp/Readme.txt
new file mode 100644
index 0000000000..b810d5b3d8
--- /dev/null
+++ b/devApps/VanillaJSTestApp/Readme.txt
@@ -0,0 +1,20 @@
+What are the dev apps?
+----------------------
+index_loginPopup.html shows how to send an email with the Microsoft Graph, using msal.js loginPopup()/acquireTokenSilent-acquireTokenPopup() APIs. The authentication happens in a popup window of the browser. 
+
+indexRedirect.html shows how to send an email with the Microsoft Graph, using msal.js loginRedirect()/acquireTokenSilent-acquireTokenRedirect() APIs. The page for the application is replaced by the authentication page, and when authentication has happened, the application is called back (on its redirectUri) with the user's idToken.
+
+How to run the dev apps:
+--------------------
+Pre-requisite
+- Install node.js if needed (https://nodejs.org/en/)
+
+Resolving the server.js references
+- In a command prompt, run npm install
+
+Running the sample
+- In a command prompt, run “node server.js”
+
+- Navigate to http://localhost:1530 with the browser of your choice
+
+- In the web page, click on the “Login” button
\ No newline at end of file