【发布时间】:2016-12-03 16:08:35
【问题描述】:
我正在尝试构建一个 (C#) 网络应用程序,允许客户与我进行约会。 我希望 Web 应用程序能够读取条目并将其添加到我的 Outlook 日历中。 许多用户将使用网络应用程序,但网络应用程序只能访问一个 Outlook 日历 - 我的。 我能够开始工作的所有示例都涉及 Web 应用程序用户交互式身份验证 - 但我的用户不会知道我的密码。 我想在网络应用程序中硬编码我的用户名/电子邮件地址和密码。
尝试获取令牌时出现错误:
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException:
AADSTS65001: The user or administrator has not consented to use the application.
Send an interactive authorization request for this user and resource.
我不是租户的管理员。有没有什么办法可以在没有管理员参与的情况下让它工作? 使用某种证书而不是用户名和密码作为用户凭据会有帮助吗?
我的代码(目前在一个简单的 C# 控制台应用程序中)如下:
UserCredential uc = new UserCredential(MyUsername, MyPassword);
var AuthContext = new AuthenticationContext("https://login.windows.net/Common");
// this doesn't work unless an unexpired token already exists
ar = AuthContext.AcquireToken("https://outlook.office365.com/", MyClientId, uc);
// this does work, but requires the app user to know the password
ar = AuthContext.AcquireToken("https://outlook.office365.com/", MyClientId, new Uri(MyReturnURI));
【问题讨论】:
标签: authentication oauth outlook authorization office365