大佬教程收集整理的这篇文章主要介绍了GetAuthenticationCookie 返回“值不能为空。参数名称:cookieHeader”的 SharePoint Online 问题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我通过 API 接口对 SharePoint Online 用户进行身份验证。在过去的几年里,它一直运行良好。但是从星期一开始我就收到错误
值不能为空。参数名称:cookieheader
有一个代码可以在 Azure 上托管的 API 中为 SharePoint Online 生成 httpclienthandler。
httpclienthandler result = new httpclienthandler();
try
{
secureString secure@R_674_5747@d = new secureString();
foreach (char c in user@R_674_5747@d) { secure@R_674_5747@d.AppendChar(c); }
SharePointOnlineCredentials credentials = new SharePointOnlineCredentials(username,secure@R_674_5747@d);
result.Credentials = credentials;
String authcookieValue = credentials.GetAuthenticationcookie(new Uri(hostWebURL));
result.cookieContainer.setcookies(new Uri(hostWebURL),authcookievalue);
}
catch (Exception eX)
{
throw ex;
}
return result;
在上面的代码行中,我们得到了‘authcookieValue’的空值。
我还使用以下命令通过 SharePoint Online Management SHell 检查了“LegacyauthprotocolsEnabled”的值,它已经是正确的。
$TenantSetTings = Get-SPOTenant
$TenantSetTings.LegacyauthprotocolsEnabled
我在某个时候开始遇到同样的错误。这显然是 Sharepoint Online 方面的变化,因为多年来我方面没有任何变化。
我认为为我修复它的关键是:
servicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
见下文:
public async Task<List<SharepointDocumentDetail>> GetFileInfoFromSharepoint(String specificFolderUrl)
{
// Once I added this,the error went away
servicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
List<SharepointDocumentDetail> ret = new List<SharepointDocumentDetail>();
var resturl = String.Format("{0}/_api/web/GetFolderByServerRelativeUrl('{1}')/Files?$expand=Files",this.Sharepoint_DocRootUrl,specificFolderUrl);
//CreaTing Credentials
var @R_674_5747@d = new SecureString();
foreach (var c in this.Sharepoint_password) @R_674_5747@d.AppendChar(c);
var credential = new SharePointOnlineCredentials(this.Sharepoint_User,@R_674_5747@d);
using (var handler = new httpClientHandler() { Credentials = credential })
{
Uri uri = new Uri(this.Sharepoint_DocRootUrl);
// I was getTing the error on this line
handler.CookieContainer.SetCookies(uri,credential.GetAuthenticationCookie(uri));
...
...
...
以上是大佬教程为你收集整理的GetAuthenticationCookie 返回“值不能为空。参数名称:cookieHeader”的 SharePoint Online 问题全部内容,希望文章能够帮你解决GetAuthenticationCookie 返回“值不能为空。参数名称:cookieHeader”的 SharePoint Online 问题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。