Skip to content

Commit

Permalink
[🔥Needs Review🔥] Use minimum Teams-JS library for mocking external OA…
Browse files Browse the repository at this point in the history
…uth (#2263)

* update

* update

* update

* update

* remove assets

* update

* correct spelling
  • Loading branch information
KangxuanYe committed Apr 11, 2024
1 parent bd4a7ac commit fce9d9f
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions apps/teams-test-app/src/public/externalOauth_end.html
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>

0 comments on commit fce9d9f

Please sign in to comment.