|
22 | 22 | clientID: "245e9392-c666-4d51-8f8a-bfd9e55b2456", |
23 | 23 | authority: "https://login.microsoftonline.com/common", |
24 | 24 | graphScopes: ["user.read", "Mail.Send"], |
25 | | - graphEndpoint: "https://graph.microsoft.com/v1.0/me" |
| 25 | + graphEndpoint: "https://graph.microsoft.com/v1.0/me", |
| 26 | + loginType: 'POPUP' |
26 | 27 | }; |
27 | 28 |
|
28 | 29 | var config = { |
|
140 | 141 | errorMessage.indexOf("interaction_required") !== -1 || |
141 | 142 | errorMessage.indexOf("login_required") !== -1; |
142 | 143 | } |
143 | | - // Browser check variables |
144 | | - var ua = window.navigator.userAgent; |
145 | | - var msie = ua.indexOf('MSIE '); |
146 | | - var msie11 = ua.indexOf('Trident/'); |
147 | | - var msedge = ua.indexOf('Edge/'); |
148 | | - var isIE = msie > 0 || msie11 > 0; |
149 | | - var isEdge = msedge > 0; |
150 | | - |
151 | | - //If you support IE, our recommendation is that you sign-in using Redirect APIs |
152 | | - //If you as a developer are testing using Edge InPrivate mode, please add "isEdge" to the if check |
153 | | - if (!isIE) { |
| 144 | + |
| 145 | + // runs on page load, change config to try different login types to see what is best for your application |
| 146 | + if (applicationConfig.loginType === 'POPUP') { |
154 | 147 | if (myMSALObj.getAccount()) {// avoid duplicate code execution on page load in case of iframe and popup window. |
155 | 148 | showWelcomeMessage(); |
156 | 149 | acquireTokenPopupAndCallMSGraph(); |
157 | 150 | } |
158 | 151 | } |
159 | | - else { |
| 152 | + else if (applicationConfig.loginType === 'REDIRECT') { |
160 | 153 | document.getElementById("SignIn").onclick = function () { |
161 | 154 | let redirectTokenRequest = { |
162 | 155 | scopes: applicationConfig.graphScopes |
|
168 | 161 | showWelcomeMessage(); |
169 | 162 | acquireTokenRedirectAndCallMSGraph(); |
170 | 163 | } |
| 164 | + } else { |
| 165 | + console.error('Please choose a valid login type'); |
171 | 166 | } |
172 | 167 | </script> |
173 | 168 | </body> |
|
0 commit comments