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

Commit ce35ffa

Browse files
committed
update lib + code changes
1 parent 749a067 commit ce35ffa

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

JavaScriptSPA/index.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
}).catch(function (error) {
6969
console.log(error);
7070
// Call acquireTokenPopup (popup window) in case of acquireTokenSilent failure due to consent or interaction required ONLY
71-
if (error.errorMessage.indexOf("consent_required") !== -1 || error.errorMessage.indexOf("interaction_required") !== -1 || error.errorMessage.indexOf("login_required") !== -1) {
71+
if (requiresInteraction(error.errorMessage)) {
7272
myMSALObj.acquireTokenPopup(tokenRequest).then(function (tokenResponse) {
7373
callMSGraph(applicationConfig.graphEndpoint, tokenResponse.accessToken, graphAPICallback);
7474
}).catch(function (error) {
@@ -97,7 +97,6 @@
9797
function showWelcomeMessage() {
9898
var divWelcome = document.getElementById('WelcomeMessage');
9999
divWelcome.innerHTML = 'Welcome ' + myMSALObj.getAccount().userName + "to Microsoft Graph API";
100-
console.log(myMSALObj.getAccount());
101100
var loginbutton = document.getElementById('SignIn');
102101
loginbutton.innerHTML = 'Sign Out';
103102
loginbutton.setAttribute('onclick', 'signOut();');
@@ -111,12 +110,11 @@
111110
scopes: applicationConfig.graphScopes
112111
};
113112
myMSALObj.acquireTokenSilent(tokenRequest).then(function (tokenResponse) {
114-
console.log(tokenResponse.scopes);
115113
callMSGraph(applicationConfig.graphEndpoint, tokenResponse.accessToken, graphAPICallback);
116114
}).catch(function (error) {
117115
console.log(error);
118116
//Call acquireTokenRedirect in case of acquireToken Failure
119-
if (error.errorMessage.indexOf("consent_required") !== -1 || error.errorMessage.indexOf("interaction_required") !== -1 || error.errorMessage.indexOf("login_required") !== -1) {
117+
if (requiresInteraction(error.errorMessage)) {
120118
myMSALObj.acquireTokenRedirect(tokenRequest);
121119
}
122120
});
@@ -134,7 +132,11 @@
134132
console.log(error);
135133
}
136134

137-
135+
function requiresInteraction(errorMessage) {
136+
return errorMessage.indexOf("consent_required") !== -1 ||
137+
errorMessage.indexOf("interaction_required") !== -1 ||
138+
errorMessage.indexOf("login_required") !== -1;
139+
}
138140
// Browser check variables
139141
var ua = window.navigator.userAgent;
140142
var msie = ua.indexOf('MSIE ');
@@ -153,10 +155,10 @@
153155
}
154156
else {
155157
document.getElementById("SignIn").onclick = function () {
156-
let tokenRequest = {
158+
let redirectTokenRequest = {
157159
scopes: applicationConfig.graphScopes
158160
};
159-
myMSALObj.loginRedirect(tokenRequest);
161+
myMSALObj.loginRedirect(redirectTokenRequest);
160162
};
161163

162164
if (myMSALObj.getAccount() && !myMSALObj.isCallback(window.location.hash)) {// avoid duplicate code execution on page load in case of iframe and popup window.

JavaScriptSPA/msal-0.9.0.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)