I am trying to use this tutorial: https://medium.com/plumsail/how-to-call-sharepoint-from-microsoft-flow-with-a-help-of-an-azure-funct... to set up custom MS Flow triggers using Azure Functions to do stuff with sharepoint docs. So, I followed the tut exactly and only changed my credentials so far. I get the following error telling me that the account is not authorized and I must first browse to the site and enable automatic login
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'.
Not really sure exactly what they mean there, but regardless my login requires mfa. Has anyone tried to do this before, is there something special I need to do when using mfa? Following is the few lines where client connection is made.
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);
Any help greatly appreciated.
edit: I've set up app registration in AD and tried using that password as an access token but that didnt work. Also tried giving the app registration extra permissions in AD -> App Registrations -> picked my app -> Required Permissions. Basically, looking for anyone who may have set up a flow with sharepoint and mfa .. or auth management with mfa in general. PLS HELP! Thanks.
Hi @nycnfc,
Please check this blog for more details about Azure functions:
https://flow.microsoft.com/en-us/blog/integrating-custom-api/
It seems that you have enabled MFA on your side, please disable it then try again to see if you will get the same issue.
Best regards,
Mabel Mao
It would literally not be legal for me to disable mfa