-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[🔥Needs Review🔥] Use minimum Teams-JS library for mocking external OA…
…uth (#2263) * update * update * update * update * remove assets * update * correct spelling
- Loading branch information
1 parent
bd4a7ac
commit fce9d9f
Showing
1 changed file
with
29 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,42 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script | ||
type="text/javascript" | ||
src=" | ||
https://res.cdn.office.net/teams-js/2.21.0/js/MicrosoftTeams.min.js" | ||
></script> | ||
<h2 style="font-size: 40px">Starting mock external oauth2</h2> | ||
</head> | ||
<body> | ||
<script> | ||
const failureMessage = { | ||
type: 'authenticationFailed', | ||
data: 'error', | ||
}; | ||
const successMessage = { | ||
type: 'authenticationSuccess', | ||
data: 'success', | ||
}; | ||
function appendLog(msg) { | ||
const element = document.createElement('p'); | ||
element.textContent = msg; | ||
document.getElementById('log').appendChild(element); | ||
} | ||
|
||
const params = new URLSearchParams(window.location.search); | ||
const titleId = params.get('titleId'); | ||
|
||
if (window.opener) { | ||
if (titleId === 'testOauthFailureTitleId') { | ||
window.opener.postMessage(failureMessage, '*'); | ||
async function callteamsJS() { | ||
if (microsoftTeams) { | ||
appendLog('successfully loaded microsoftTeams'); | ||
try { | ||
await microsoftTeams.app.initialize(); | ||
if (titleId === 'testOauthFailureTitleId') { | ||
microsoftTeams.authentication.notifyFailure('Failed'); | ||
appendLog('notifyFailure sent'); | ||
} else { | ||
microsoftTeams.authentication.notifySuccess('Success'); | ||
appendLog('notifySuccess sent'); | ||
} | ||
} catch (e) { | ||
appendLog('Error calling teams js: ' + e); | ||
} | ||
} else { | ||
window.opener.postMessage(successMessage, '*'); | ||
appendLog('no microsoftTeams'); | ||
} | ||
} | ||
</script> | ||
</body> | ||
</head> | ||
<div id="log"></div> | ||
<body onload="callteamsJS()"></body> | ||
</html> |