office365 - 我的应用程序中的 office 365 登录身份验证
问题描述
我们计划为用户提供使用 Office 365 帐户登录的规定。我想知道任何论坛来指导集成。
我的应用程序 API:WebAPi (C#) 前端:Angular 6
解决方案
请参考以下示例:
protected void btnLogin_Click(object sender, EventArgs e)
{
bool result = false;
HttpResponse < string > response = Unirest.get("https://outlook.office365.com/api/v1.0/me/").basicAuth(txtEmail.Text, txtPassword.Text).asJson < string > ();
if (response.Code == 200)
result = true;
if (result)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('User validated successfully')", true);
} else
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Email/Password is wrong')", true);
}
}
您将获得如下数据。这是样本数据。
{
"@odata.context": "https://outlook.office365.com/api/v1.0/$metadata#Me",
"@odata.id": "https://outlook.office365.com/api/v1.0/Users('yourName@companyName.com')",
"Id": "yourId",
"DisplayName": "Your Display Name",
"Alias": "aliasName",
"MailboxGuid": "mailBoxGuid"
}
有关更多信息,请参阅以下链接:
推荐阅读
- c# - 如何从 C# 正确执行链接服务器存储过程
- r - 组上两列的测试条件
- usb - USB-MIDI 事件数据包中的电缆编号字段代表什么?
- postgresql - docker 容器中 PostgreSQL 的权限问题
- visual-studio-code - 将 git-bash 与 Visual Studio 代码一起使用
- selenium - Cucumber 场景嵌入两次导致使用相同文件名拍摄的两个屏幕截图
- angular - Angular 2访问模板中的表单元素
- c# - 通用处理程序未显示为可用选项。我怎样才能添加它?
- adsutil.vbs - 如何创建一个脚本,该脚本仅删除保存脚本的同一文件夹中的某些文件
- python - Python dash Div 整页背景图片