使用LiveId(Microsoft帐户)C#进行SharePoint Online身份验证 [英] SharePoint Online Authentication using LiveId (Microsoft Account) C#
问题描述
我正在尝试使用客户端对象模型从SharePoint Online网站下载文件.我需要使用已经在此站点上受邀的Microsoft帐户.我尝试使用此NuGet包
Microsoft.SharePointOnline.CSOM
I'm trying to use client side object model to download files from SharePoint Online site. I need to use Microsoft account that already has been invited on this site. I tried to use this NuGet Package
Microsoft.SharePointOnline.CSOM
使用(var context = new ClientContext("https://somesite.sharepoint.com/"))
{
var passWord = new SecureString();
foreach("xxxxx.1"中的var c)passWord.AppendChar(c);
context.Credentials =新的SharePointOnlineCredentials("myEmail_MicrosoftAccount@gmail.com",passWord);
var web = context.Web;
context.Load(web);
context.ExecuteQuery();
Console.WriteLine(newFile.Url);
}
using (var context = new ClientContext("https://somesite.sharepoint.com/"))
{
var passWord = new SecureString();
foreach (var c in "xxxxx.1") passWord.AppendChar(c);
context.Credentials = new SharePointOnlineCredentials("myEmail_MicrosoftAccount@gmail.com", passWord);
var web = context.Web;
context.Load(web);
context.ExecuteQuery();
Console.WriteLine(newFile.Url);
}
但是我在这行代码"context.ExecuteQuery()"中遇到此错误
身份客户端运行时库(IDCRL)无法查找联合登录的领域信息.
问:您知道如何使用Microsoft帐户身份验证来联机访问SharePoint吗?也许您可以共享一些代码段?
But I'm getting this Error on this line of code "context.ExecuteQuery()"
'Identity Client Runtime Library (IDCRL) could not look up the realm information for a federated sign-in.
Q: Do you know how to get an access to the SharePoint online using Microsoft Account authentication? Maybe you can share some code snippets?
推荐答案
据我了解,SharePoint Online帐户是一种Microsoft电子邮件帐户格式,如下所示:
As I understand, the SharePoint Online account is a Microsoft email account format like below:
username@TenantName.onmicrosoft.com
我在您的代码段中看到,您正在使用带有gmail的电子邮件地址,因此建议您将其替换为上述Microsoft电子邮件格式,以检查其是否有效.
I saw in your code snippet, you are using a email address with gmail, so I suggest you can replace it with a Microsoft email format like above to check if it works.
有关使用C#控制台应用程序连接SharePoint Online的详细代码段,请参阅:
About detailed code snippet to connect SharePoint Online using C# console application, please refer:
连接使用控制台应用程序到Office 365中的SharePoint Online
谢谢
最好的问候
这篇关于使用LiveId(Microsoft帐户)C#进行SharePoint Online身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!