【发布时间】:2021-07-22 10:45:53
【问题描述】:
以前我可以使用任务模块和 iframe 将 youtube 嵌入到 Microsoft 团队的 Adaptive Card 中,但我知道 Microsoft Stream 没有向公众分享视频的功能。因此,当 URL 视频设置为 Microsoft Stream Video 时,Iframe 将显示“登录和登录页面”,当单击该标志时,它会打开一个新浏览器。我想在 Microsoft 团队任务模块中播放视频,我认为它已经使用 SSO 并且不需要任何标志。 这是任务模块的截图
这是我的 iframe 页面源代码
import React, { Component } from 'react';
import './SeeDetail.css';
import * as microsoftTeams from "@microsoft/teams-js";
import i18n from '../../i18n';
import { getUrlVideo } from '../../apis/messageListApi';
import axios, { AxiosResponse, AxiosRequestConfig } from "axios";
export default class SeeDetail extends Component {
constructor(props) {
super(props);
this.state = {
video: ""
}
}
async componentDidMount() {
microsoftTeams.initialize();
const video = this.getQueryVariable('video');
const authTokenRequest = {
url: window.location.origin + "/signin-simple-start",
successCallback: (token) => {
this.setState({ video: video });
},
failureCallback: (error) => {
// When the getAuthToken function returns a "resourceRequiresConsent" error,
// it means Azure AD needs the user's consent before issuing a token to the app.
// The following code redirects the user to the "Sign in" page where the user can grant the consent.
// Right now, the app redirects to the consent page for any error.
microsoftTeams.authentication.authenticate({
url: window.location.origin + "/signin-simple-start",
successCallback: () => {
console.log("Login succeeded!");
this.setState({ video: video });
},
failureCallback: (reason) => {
console.log("Login failed: " + reason);
window.location.href = `/errorpage?locale=${i18n.language}`;
}
});
},
resources: []
};
microsoftTeams.authentication.getAuthToken(authTokenRequest);
}
getQueryVariable(variable) {
var query = window.location.search.substring(1);
console.log(query)//"app=article&act=news_content&aid=160990"
var vars = query.split("&");
console.log(vars) //[ 'app=article', 'act=news_content', 'aid=160990' ]
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
console.log(pair)//[ 'app', 'article' ][ 'act', 'news_content' ][ 'aid', '160990' ]
if (pair[0] == variable) { return pair[1]; }
}
return (false);
}
render() {
return (
<div className="container" >
<iframe id="my_iframe" src={this.state.video} className="responsive-iframe" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen="allowfullscreen"></iframe>
</div>
)
}
}
我不知道是否可以在任务模块中观看 Microsoft Stream。也许我错过了登录方法?我以为 Sign-in 方法只适用于 Axios 调用。
【问题讨论】:
-
您是否在清单中的有效域中添加了 Microsoft 流 url?
-
好吧,让我先添加它,但它应该正确显示您是否曾经使用 Microsoft 流作为任务模块的 iframe 内容。我仍然不确定这是否可以完成,因为我在这里找不到任何文件。甚至团队的默认流功能也会重定向到新浏览器
-
@Mamatha-MSFT 我已经有这两个域 companycommunicatorkre.azurefd.net, microsoftstream.com 但仍然没有什么不同。 Microsoft Stream 仍需要身份验证
-
@Mamatha-MSFT 嗨,用更新的代码更新我的问题,你知道为什么我收到“未找到定义”错误,错误的含义是什么?
标签: javascript reactjs stream microsoft-teams