首页 > 解决方案 > 我的应用程序中的 office 365 登录身份验证

问题描述

我们计划为用户提供使用 Office 365 帐户登录的规定。我想知道任何论坛来指导集成。

我的应用程序 API:WebAPi (C#) 前端:Angular 6

标签: office365

解决方案


请参考以下示例:

   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# 中使用 Office 365 进行身份验证

使用 Visual Studio MVC 应用程序的 Office 365 身份验证


推荐阅读