Skip to content
This repository has been archived by the owner. It is now read-only.

Commit 88eb256

Browse files
committed
Updating B2C Sample with CDN
1 parent 0c04872 commit 88eb256

File tree

5 files changed

+21
-10326
lines changed

5 files changed

+21
-10326
lines changed

index.html

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222

2323
<body>
2424
<!-- bluebird only needed if this page needs to run on Internet Explorer -->
25+
<!-- msal.min.js can be used in the place of msal.js; included msal.js to make debug easy -->
2526
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js" class="pre"></script>
26-
<script src="msal.js"></script>
27+
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/1.0.0/js/msal.js"></script>
2728
<script src="https://code.jquery.com/jquery-3.2.1.min.js" class="pre"></script>
2829

2930
<h2>Getting an access token with Azure AD B2C and calling a Web API</h2>
@@ -36,37 +37,43 @@ <h2>Getting an access token with Azure AD B2C and calling a Web API</h2>
3637
<pre class="response"></pre>
3738

3839
<script class="pre">
40+
3941
// The current application coordinates were pre-registered in a B2C tenant.
40-
var applicationConfig = {
41-
clientID: 'e760cab2-b9a1-4c0d-86fb-ff7084abd902',
42-
authority: "https://login.microsoftonline.com/tfp/fabrikamb2c.onmicrosoft.com/b2c_1_susi",
42+
var appConfig = {
4343
b2cScopes: ["https://fabrikamb2c.onmicrosoft.com/helloapi/demo.read"],
44-
webApi: 'https://fabrikamb2chello.azurewebsites.net/hello',
44+
webApi: "https://fabrikamb2chello.azurewebsites.net/hello"
4545
};
4646
</script>
4747

4848
<script>
4949
"use strict";
5050

51-
var config = {
52-
auth: {
53-
clientId: applicationConfig.clientID,
54-
authority: applicationConfig.authority,
55-
}
51+
// configuration to initialize msal
52+
var msalConfig = {
53+
auth: {
54+
clientId: "e760cab2-b9a1-4c0d-86fb-ff7084abd902", //This is your client ID
55+
authority: "https://login.microsoftonline.com/tfp/fabrikamb2c.onmicrosoft.com/b2c_1_susi" //This is your tenant info
56+
},
57+
cache: {
58+
cacheLocation: "localStorage",
59+
storeAuthStateInCookie: true
60+
}
5661
};
5762

5863
var clientApplication = new Msal.UserAgentApplication(config);
64+
65+
// Register a call back for redirect flow
5966
// myMSALObj.handleRedirectCallback(authRedirectCallback);
6067

6168
function login() {
6269

6370
var loginRequest = {
64-
scopes: applicationConfig.b2cScopes
71+
scopes: appConfig.b2cScopes
6572
};
6673

6774
clientApplication.loginPopup(loginRequest).then(function (loginResponse) {
6875
var tokenRequest = {
69-
scopes: applicationConfig.b2cScopes
76+
scopes: appConfig.b2cScopes
7077
};
7178

7279
clientApplication.acquireTokenSilent(tokenRequest).then(function (tokenResponse) {
@@ -98,7 +105,7 @@ <h2>Getting an access token with Azure AD B2C and calling a Web API</h2>
98105

99106
function callApi() {
100107
var tokenRequest = {
101-
scopes: applicationConfig.b2cScopes
108+
scopes: appConfig.b2cScopes
102109
}
103110
clientApplication.acquireTokenSilent(tokenRequest).then(function (tokenResponse) {
104111
callApiWithAccessToken(tokenResponse.accessToken);
@@ -115,7 +122,7 @@ <h2>Getting an access token with Azure AD B2C and calling a Web API</h2>
115122
// Call the Web API with the AccessToken
116123
$.ajax({
117124
type: "GET",
118-
url: applicationConfig.webApi,
125+
url: appConfig.webApi,
119126
headers: {
120127
'Authorization': 'Bearer ' + accessToken,
121128
},

0 commit comments

Comments
 (0)