【发布时间】:2018-01-09 03:41:55
【问题描述】:
我正在尝试使用本教程:https://medium.com/plumsail/how-to-call-sharepoint-from-microsoft-flow-with-a-help-of-an-azure-function-a5740794341 使用 Azure Functions 设置自定义 MS Flow 触发器来处理共享点文档。所以,我完全遵循了 tut,到目前为止只更改了我的凭据。
我收到以下错误,告诉我该帐户未经授权,我必须先浏览到该站点并启用自动登录
2018-01-03T21:11:01.889 Exception while executing function: Functions.CreateFolder. Microsoft.Azure.WebJobs.Script: One or more errors occurred. Microsoft.SharePoint.Client.Runtime: Cannot contact web site 'https://mysite.sharepoint.com/' or the web site does not support SharePoint Online credentials. The response status code is 'Unauthorized'. The response headers are 'X-SharePointHealthScore=0, X-MSDAVEXT_Error=917656; Access+denied.+Before+opening+files+in+this+location%2c+you+must+first+browse+to+the+web+site+and+select+the+option+to+login+automatically., SPRequestGuid=9c003d9e-9090-5000-1519-82d69fd4d838, request-id=9c003d9e-9090-5000-1519-82d69fd4d838, MS-CV=nj0AnJCQAFAVGYLWn9TYOA.0, Strict-Transport-Security=max-age=31536000, X-FRAME-OPTIONS=SAMEORIGIN, SPRequestDuration=29, SPIisLatency=0, MicrosoftSharePointTeamServices=16.0.0.7206, X-Content-Type-Options=nosniff, X-MS-InvokeApp=1; RequireReadOnly, Content-Length=0, Content-Type=text/plain; charset=utf-8, Date=Wed, 03 Jan 2018 21:11:01 GMT, P3P=CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI", Server=Microsoft-IIS/8.5, X-Powered-By=ASP.NET'.
不太确定它们在那里的确切含义,但不管我的登录是否需要 mfa。以前有没有人尝试过这样做,使用 mfa 时我需要做些什么特别的事情吗?以下是建立客户端连接的几行。
string userName = System.Environment.GetEnvironmentVariable("SharePointUser", EnvironmentVariableTarget.Process);
string password = System.Environment.GetEnvironmentVariable("SharePointPassword", EnvironmentVariableTarget.Process);
var authenticationManager = new PnPAuthenticationManager();
var clientContext = authenticationManager.GetSharePointOnlineAuthenticatedContextTenant(sharePointSiteUrl, userName, password);
var pnpClientContext = PnPClientContext.ConvertFrom(clientContext);
非常感谢任何帮助。
编辑:
【问题讨论】:
-
我认为问题出在 MFA 上。 sharepoint 中是否有等效的 Service Principal user 可以在具有适当权限的自动化工具中使用?
-
我们使用 AD 来管理帐户,所以我尝试创建一个 SP 用户,然后通过几个身份验证管理器方法使用该应用程序 ID 和密码。我通过 AD -> 应用注册 -> 所需权限授予应用 Sharepoint 权限。我还尝试仅使用应用程序注册来授予包含我的功能和所有权限的资源组,使用该应用程序 ID/秘密,使用应用程序密码。我现在被禁止而不是未经授权,所以我想这是一个权限问题,但不确定我还能做什么。你有没有做过类似的事情?
-
使用 ServicePrincipalUser 是自动化工具的最佳方式。我建议先尝试在 Azure Functions 之外使用 SP 凭据,以确保您获得正确的权限。这是SP setup credentials 在资源组中具有正确权限的示例。希望这会有所帮助。
-
让它与 sp 用户一起工作,感谢您的信息!
-
太棒了。将移步回答。
标签: c# azure sharepoint azure-functions