我正在使用VueJS 2.x框架设置应用程序,它需要通过Azure Active Directory服务对用户进行身份验证.我已经拥有该服务的"登录信息"(Auth和令牌URL).
到目前为止,我只遇到过一篇文章,显示了VueJS中的设置,但它依赖于第三方服务(Auth0) - 在此过程中添加了不必要的卷积.
当没有任何VueJS npm模块允许轻松进行身份验证时,如何继续?或者您是否必须依赖Vue之外的图书馆,如Adal JS?
任何的意见都将会有帮助.
我似乎在为我的应用程序授予访问组织电子邮件中的另一个用户所需的权限时遇到问题。我让我的管理员通过 Azure 门户授予我的应用程序所有可能的权限,并且我在从 Graph 网站下载的测试应用程序中收到“访问被拒绝”错误。这让我觉得我可能没有使用正确的 API 调用。
这是我用来检索另一个用户的电子邮件的代码:
IMailFolderMessagesCollectionPage messages = await graphClient.Users["userID"].MailFolders.Inbox.Messages.Request().Top(25).GetAsync();
Run Code Online (Sandbox Code Playgroud)
其中“userID”是我通过图形浏览器获取组织中所有用户获得的 id 值。
完整代码:
(控制器)
[Authorize]
public async Task<ActionResult> GetEmails()
{
try
{
// Initialize the GraphServiceClient.
GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient();
ResultsViewModel results = new ResultsViewModel();
// Get the messages.
results.Items = await graphService.GetMyInboxMessages(graphClient);
return View("Graph", results);
}
catch (ServiceException se)
{
if (se.Error.Code == Resource.Error_AuthChallengeNeeded) return new EmptyResult();
return RedirectToAction("Index", "Error", new { message = Resource.Error_Message + Request.RawUrl + ": " + se.Error.Message });
}
} …Run Code Online (Sandbox Code Playgroud) c# asp.net-mvc azure azure-active-directory microsoft-graph-api