我开发了一个自定义 Teams 应用程序,它有一个基本选项卡,用户必须在查看某些内容之前登录。 身份验证通过 Oauth2 代码流,使用外部 npm 包 (@openid/appauth)。 我创建了这段代码,用于在用户点击登录按钮时打开弹出窗口:
IAsyncResult
这个函数:teamsAuthRequest 只是用于调用授权端点的配置:
login = () => {
const successCallback = (result) => {
this.props.setLogged(result);
}
const failureCallback = (error) => {
logger.warn(JSON.stringify(error));
this.props.setError(error);
}
authClient.teamsAuthRequest(this.props.user.PartitionKey, this.props.user.RowKey, successCallback, failureCallback);
}
它通过以下代码调用一个打开弹出窗口的函数:
teamsAuthRequest: async (tid, aaId, successCallback, failureCallback) => {
const config = await createConfiguration();
const request = createAuthRequest(tid, aaId);
teamsHandler.performAuthorizationRequest(config, request, successCallback, failureCallback);
}
如果我使用团队网络,它会正确打开弹出窗口并在登录后关闭它。
如果我在团队桌面中使用相同的应用程序,它会正确打开弹出窗口,但它不会调用 notifySuccess 函数,也不会关闭弹出窗口。
当我收到来自外部提供商的回调以接收授权代码时,我运行此代码:
microsoftTeams.authentication.authenticate({
url: url,
width: 600,
height: 550,
successCallback: function (result) {
successCallback(result);
},
failureCallback: function (reason) {
failureCallback(reason)
}
});
我该如何解决?
答案 0 :(得分:1)
Teams 基本上会使用 microsoftTeams.authentication.authenticate
为您启动一个登录弹出窗口。结果,即使您-看到-一个弹出窗口,您实际上想要使用重定向流程。请在此处查看说明此内容的示例应用
https://github.com/pnp/teams-dev-samples/tree/master/samples/tab-sso