【发布时间】:2018-01-24 22:58:01
【问题描述】:
所以我构建了一个简单的应用程序,并尝试将 Outlook 的 API 集成到其中。我创建了一个 Outlook 帐户,注册了一个应用程序并使用密钥设置了所有内容。当它把我带到 Azure 登录页面时,我使用我注册应用程序的帐户登录,并且我能够返回帐户日历的 JSON 数据。
但是,当我尝试另一个 Outlook 帐户时,我遇到了问题:
getUserEmail returned an error: [object Object]
这是以下函数:
// Function to retrieve email in order to find user
async function getUserEmail(token) {
// Create a Graph client
const client = microsoftGraph.Client.init({
authProvider: done => {
// First parameter is is error handling if no token is retrieved
// If token is available then return the token
done(null, token);
}
});
const res = await client.api('/me').get();
// Outlook.com users have userPrincipalName instead of a mail attribute
return res.mail ? res.mail : res.userPrincipalName;
}
解决错误本身会返回此消息:
all the offeractions provided in the property bag cannot be validated for the token
我现在真的很困惑,为什么我只能使用我注册应用程序的帐户访问数据?我是否需要更改应用注册中的其他内容?
【问题讨论】:
-
确保您在登录期间提供了正确的权限范围。
标签: javascript azure email outlook-restapi