我想将Teams集成到我的Vue应用程序中。这就是为什么我没有本机应用程序(使用React),而只使用基本软件包的原因。
我想与团队合作,并通过 ngrok 将我的Vue应用集成到标签面板。首先,我使用了文档中的这段代码
// Error Handler
app.use(function(err, req, res, next) {
console.error(err)
if (!err.statusCode) err.statusCode = 500;
let msg = err.message
// Do not expose 500 error messages in production, to the client
if (process.env.NODE_ENV === "production" && err.statusCode === 500) {
msg = "Internal Server Error"
}
res.status(err.statusCode).send(msg)
})
我在Vue实例的import * as microsoftTeams from '@microsoft/teams-js';
import * as AuthenticationContext from 'adal-angular/lib/adal';
export default {
async function signIn() {
await microsoftTeams.initialize();
microsoftTeams.getContext(async context => {
const { loginHint: aDUserMailAdress } = context;
let extraQueryParameter = 'scope=openid+profile';
if (aDUserMailAdress) {
const encodedADUserMailAdress = encodeURIComponent(aDUserMailAdress);
extraQueryParameter += `&login_hint=${encodedADUserMailAdress}`;
}
const clientId = '1902f997-d6e8-4740-9412-e12dee41c451';
const aDConfig = {
clientId,
redirectUri: 'https://login.microsoftonline.com/common/oauth2/nativeclient',
cacheLocation: 'localStorage',
navigateToLoginRequestUrl: false,
extraQueryParameter,
};
const authContext = new AuthenticationContext(aDConfig);
const user = await authContext.getCachedUser();
if (user) { // This is null
if (user.profile.oid !== userObjectId) {
authContext.clearCache();
}
}
authContext.acquireToken(clientId, (errorDescription, token, err, tokenType) => {
if (err) {
throw new Error(errorDescription);
}
if (token) {
let authToken = token;
if (tokenType !== authContext.CONSTANTS.ID_TOKEN) {
authToken = authContext.getCachedToken(clientId);
}
debugger;
} else {
debugger;
}
});
});
},
};
钩子中调用signIn
。代码似乎工作正常,已设置mounted
。不幸的是authContext
为空,所以我没有缓存的用户。此外,user
的回调会引发以下错误消息
令牌更新操作由于超时而失败
什么是错的或丢失的?