Skip to content

Commit

Permalink
build: upgrade teams-js (#1272)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yimin-Jin committed May 14, 2024
1 parent d2b34c0 commit f9367c4
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 95 deletions.
2 changes: 1 addition & 1 deletion intelligent-data-chart-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@fluentui/react": "^8.114.2",
"@fluentui/react-components": "^9.44.2",
"@fluentui/react-icons": "^2.0.224",
"@microsoft/teams-js": "^2.18.0",
"@microsoft/teams-js": "^2.22.0",
"@microsoft/teamsfx": "^2.3.0",
"@microsoft/teamsfx-react": "^3.1.0",
"axios": "^1.6.5",
Expand Down
59 changes: 30 additions & 29 deletions intelligent-data-chart-generator/public/auth-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<body>
<script
src="https://statics.teams.cdn.office.net/sdk/v1.6.0/js/MicrosoftTeams.min.js"
integrity="sha384-mhp2E+BLMiZLe7rDIzj19WjgXJeI32NkPvrvvZBrMi5IvWup/1NUfS5xuYN5S3VT"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<script
Expand All @@ -22,34 +22,35 @@
var currentURL = new URL(window.location);
var clientId = currentURL.searchParams.get("clientId");

microsoftTeams.initialize();
microsoftTeams.getContext(async function (context) {
const msalConfig = {
auth: {
clientId: clientId,
authority: `https://login.microsoftonline.com/${context.tid}`,
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: "sessionStorage",
},
}
microsoftTeams.app.initialize().then(() => {
microsoftTeams.getContext(async function (context) {
const msalConfig = {
auth: {
clientId: clientId,
authority: `https://login.microsoftonline.com/${context.tid}`,
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: "sessionStorage",
},
}

const msalInstance = new window.msal.PublicClientApplication(msalConfig);
msalInstance.handleRedirectPromise()
.then((tokenResponse) => {
if (tokenResponse !== null) {
microsoftTeams.authentication.notifySuccess(JSON.stringify({
sessionStorage: sessionStorage
}));
} else {
microsoftTeams.authentication.notifyFailure("Get empty response.");
}
})
.catch((error) => {
microsoftTeams.authentication.notifyFailure(JSON.stringify(error));
});
})
const msalInstance = new window.msal.PublicClientApplication(msalConfig);
msalInstance.handleRedirectPromise()
.then((tokenResponse) => {
if (tokenResponse !== null) {
microsoftTeams.authentication.notifySuccess(JSON.stringify({
sessionStorage: sessionStorage
}));
} else {
microsoftTeams.authentication.notifyFailure("Get empty response.");
}
})
.catch((error) => {
microsoftTeams.authentication.notifyFailure(JSON.stringify(error));
});
})
});
</script>
</body>
</html>
60 changes: 30 additions & 30 deletions intelligent-data-chart-generator/public/auth-start.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<body>
<script
src="https://statics.teams.cdn.office.net/sdk/v1.6.0/js/MicrosoftTeams.min.js"
integrity="sha384-mhp2E+BLMiZLe7rDIzj19WjgXJeI32NkPvrvvZBrMi5IvWup/1NUfS5xuYN5S3VT"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<script
Expand All @@ -19,36 +19,36 @@
crossorigin="anonymous">
</script>
<script type="text/javascript">
microsoftTeams.initialize();
microsoftTeams.app.initialize().then(() => {
// Get the tab context, and use the information to navigate to Azure AD login page
microsoftTeams.getContext(async function (context) {
// Generate random state string and store it, so we can verify it in the callback
var currentURL = new URL(window.location);
var clientId = currentURL.searchParams.get("clientId");
var scope = currentURL.searchParams.get("scope");
var loginHint = currentURL.searchParams.get("loginHint");

// Get the tab context, and use the information to navigate to Azure AD login page
microsoftTeams.getContext(async function (context) {
// Generate random state string and store it, so we can verify it in the callback
var currentURL = new URL(window.location);
var clientId = currentURL.searchParams.get("clientId");
var scope = currentURL.searchParams.get("scope");
var loginHint = currentURL.searchParams.get("loginHint");
const msalConfig = {
auth: {
clientId: clientId,
authority: `https://login.microsoftonline.com/${context.tid}`,
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: "sessionStorage",
},
}

const msalConfig = {
auth: {
clientId: clientId,
authority: `https://login.microsoftonline.com/${context.tid}`,
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: "sessionStorage",
},
}

const msalInstance = new msal.PublicClientApplication(msalConfig);
const scopesArray = scope.split(" ");
const scopesRequest = {
scopes: scopesArray,
redirectUri: window.location.origin + `/auth-end.html?clientId=${clientId}`,
loginHint: loginHint,
prompt : "consent"
};
await msalInstance.loginRedirect(scopesRequest);
const msalInstance = new msal.PublicClientApplication(msalConfig);
const scopesArray = scope.split(" ");
const scopesRequest = {
scopes: scopesArray,
redirectUri: window.location.origin + `/auth-end.html?clientId=${clientId}`,
loginHint: loginHint,
prompt : "consent"
};
await msalInstance.loginRedirect(scopesRequest);
});
});
</script>
</body>
Expand Down
11 changes: 6 additions & 5 deletions team-central-dashboard/public/auth-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<body>
<script
src="https://statics.teams.cdn.office.net/sdk/v1.6.0/js/MicrosoftTeams.min.js"
integrity="sha384-mhp2E+BLMiZLe7rDIzj19WjgXJeI32NkPvrvvZBrMi5IvWup/1NUfS5xuYN5S3VT"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<script
Expand All @@ -22,8 +22,8 @@
var currentURL = new URL(window.location);
var clientId = currentURL.searchParams.get("clientId");

microsoftTeams.initialize();
microsoftTeams.getContext(async function (context) {
microsoftTeams.app.initialize().then(() => {
microsoftTeams.getContext(async function (context) {
const msalConfig = {
auth: {
clientId: clientId,
Expand All @@ -49,7 +49,8 @@
.catch((error) => {
microsoftTeams.authentication.notifyFailure(JSON.stringify(error));
});
})
});
});
</script>
</body>
</html>
60 changes: 30 additions & 30 deletions team-central-dashboard/public/auth-start.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<body>
<script
src="https://statics.teams.cdn.office.net/sdk/v1.6.0/js/MicrosoftTeams.min.js"
integrity="sha384-mhp2E+BLMiZLe7rDIzj19WjgXJeI32NkPvrvvZBrMi5IvWup/1NUfS5xuYN5S3VT"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<script
Expand All @@ -19,36 +19,36 @@
crossorigin="anonymous">
</script>
<script type="text/javascript">
microsoftTeams.initialize();
microsoftTeams.app.initialize().then(() => {
// Get the tab context, and use the information to navigate to Azure AD login page
microsoftTeams.getContext(async function (context) {
// Generate random state string and store it, so we can verify it in the callback
var currentURL = new URL(window.location);
var clientId = currentURL.searchParams.get("clientId");
var scope = currentURL.searchParams.get("scope");
var loginHint = currentURL.searchParams.get("loginHint");

// Get the tab context, and use the information to navigate to Azure AD login page
microsoftTeams.getContext(async function (context) {
// Generate random state string and store it, so we can verify it in the callback
var currentURL = new URL(window.location);
var clientId = currentURL.searchParams.get("clientId");
var scope = currentURL.searchParams.get("scope");
var loginHint = currentURL.searchParams.get("loginHint");
const msalConfig = {
auth: {
clientId: clientId,
authority: `https://login.microsoftonline.com/${context.tid}`,
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: "sessionStorage",
},
}

const msalConfig = {
auth: {
clientId: clientId,
authority: `https://login.microsoftonline.com/${context.tid}`,
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: "sessionStorage",
},
}

const msalInstance = new msal.PublicClientApplication(msalConfig);
const scopesArray = scope.split(" ");
const scopesRequest = {
scopes: scopesArray,
redirectUri: window.location.origin + `/auth-end.html?clientId=${clientId}`,
loginHint: loginHint,
prompt : "consent"
};
await msalInstance.loginRedirect(scopesRequest);
const msalInstance = new msal.PublicClientApplication(msalConfig);
const scopesArray = scope.split(" ");
const scopesRequest = {
scopes: scopesArray,
redirectUri: window.location.origin + `/auth-end.html?clientId=${clientId}`,
loginHint: loginHint,
prompt : "consent"
};
await msalInstance.loginRedirect(scopesRequest);
});
});
</script>
</body>
Expand Down

0 comments on commit f9367c4

Please sign in to comment.