Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
kaiac
Frequent Visitor

We Couldn't authenticate with the credentials provided. Please try again

Hi,


I’ve done so much research in the Power BI Community, YouTube, etc., but still cannot find a solution for my case. Please Help me!

 

 

There are various monthly data files (e.g., 202308.xlsx, 202309.xlsx, …) stored in our corporate SharePoint folder. I need the data to be loaded and refreshed in Power BI Service automatically every month. The purpose of the M code below is to load Excel data for the current and previous months since I’d like to create a month-over-month visualization. It works in Power BI Desktop, but I encounter errors when attempting to refresh the dataset after it has been published to PowerBI.com.


Here’s my M code:

let
CurrentDate = DateTime.ToText(DateTime.LocalNow(), "yyyyMM"),
PreviousMonthDate = DateTime.From(Date.From(Date.AddMonths(DateTime.LocalNow(), -1))),
PreviousMonth = DateTime.ToText(PreviousMonthDate, "yyyyMM"),
CustomStepValue = Text.From(#"PreviousMonth"),
#"SharePoint Folder Source" = Excel.Workbook(Web.Contents("https://XXX.sharepoint.com/sites/XXX/XXX/XXXX/XX/XXX/X/X/51.Power%20BI/" & CustomStepValue & ".xlsx"), null, true),
Navigation = #"SharePoint Folder Source"{[Item="sales",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Navigation, [PromoteAllScalars=true])
in
#"Promoted Headers"

 

So I've tried using approaches like the RelativePath option Chris Webb and others shared but kept getting this error “We Couldn't authenticate with the credentials provided. Please try again”.

Update on 9/20/23: Just want to be clear, I can connect an excel file of a SharePoint Online folder via Web connector sucessfully, but I got the same error when trying connecting a SharePoint Online folder via either Web or SharePoint Folder connector.

 

let
CurrentDate = DateTime.ToText(DateTime.LocalNow(), "yyyyMM"),
PreviousMonthDate = DateTime.From(Date.From(Date.AddMonths(DateTime.LocalNow(), -1))),
PreviousMonth = DateTime.ToText(PreviousMonthDate, "yyyyMM"),
CustomStepValue = Text.From(#"PreviousMonth"),
#"SharePoint Folder Source" = Excel.Workbook(
Web.Contents("https://XXX.sharepoint.com/sites",
[RelativePath="/XXX/XXX/XXXX/XX/XXX/X/X/51.Power%20BI/" & CustomStepValue &".xlsx"]), null, true),
Navigation = #"SharePoint Folder Source"{[Item="sales",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Navigation, [PromoteAllScalars=true])

in
#"Promoted Headers"

 

Screenshot 2023-09-15 155741.pngScreenshot 2023-09-15 155859.png

 

I've tried each potential solution from the Power BI Community, such as data source settings, but still cannot solve this problem. I also consulted with our IT team, but it seems that they had no idea either...

4 REPLIES 4
Anonymous
Not applicable

Have you tried Windows as the auth type?

 

--Nate

Hi Nate,

 

Yes, and I got the same result.

mlsx4
Memorable Member
Memorable Member

Hi @kaiac 

 

Even if it is an organizational account, have you tried to change the type of privacy level or the type of accesing? I think you need to choose "OAuth2" in Authentication method. 

 

Some people say you can solve it following these steps:

  1. Go to File in Power BI Desktop
  2. Select Options an settings -> Options -> Security -> Authentication Browser
  3. Enable Use my default web browser.

 

Please, check this link too, just in case it helps: https://community.fabric.microsoft.com/t5/Issues/Can-t-connect-to-Sharepoint/idi-p/1868488

kaiac
Frequent Visitor

Hi @mlsx4, thank you for replying!

 

Regarding the privacy level, I couldn't find "OAuth2" in either Power BI desktop or service. I also attempted to enable the default web browser for authentication, but it still didn't work.

 

I did visit the link and copied Microsoft.Web.WebView2.Core.dll into the bin folder. However, after this, I encountered errors when trying to open a PBIX file. It seems to be a similar issue as the one mentioned in this post (Unable to refresh - Microsoft Fabric Community), although I didn't receive the exact same error as that user did.

 

Feedback Type:
Frown (Error)

Error Message:
Resolution of the dependency failed, type = "Microsoft.PowerBI.Client.Windows.MainForm", name = "(none)".
Exception occurred while: Calling constructor Microsoft.PowerBI.Client.Windows.MainForm(Microsoft.Mashup.Client.UI.Shared.ILegacyUIHost uiHost, Microsoft.PowerBI.Client.Shared.IPowerBISettings powerBISettings, Microsoft.PowerBI.Client.Windows.IBrowserFactory browserFactory, Microsoft.PowerBI.Client.Windows.Services.IPowerBITelemetryService telemetryService, Microsoft.PowerBI.Client.Windows.Services.IPowerBIWindowServiceFactory windowServiceFactory, Microsoft.PowerBI.Client.Windows.Services.IUIBlockingService uiBlockingService, Microsoft.PowerBI.Client.Windows.Diagnostics.IDiagnosticInformationService diagnosticsInfoService, Microsoft.PowerBI.Client.Shared.ISystemEnvironment systemEnvironment, Microsoft.PowerBI.Client.Windows.Services.IEventAggregationService eventAggregationService).
Exception is: FileNotFoundException - Could not load file or assembly 'System.ComponentModel.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
-----------------------------------------------
At the time of the exception, the container was:
  Resolving Microsoft.PowerBI.Client.Windows.MainForm,(none)
  Calling constructor Microsoft.PowerBI.Client.Windows.MainForm(Microsoft.Mashup.Client.UI.Shared.ILegacyUIHost uiHost, Microsoft.PowerBI.Client.Shared.IPowerBISettings powerBISettings, Microsoft.PowerBI.Client.Windows.IBrowserFactory browserFactory, Microsoft.PowerBI.Client.Windows.Services.IPowerBITelemetryService telemetryService, Microsoft.PowerBI.Client.Windows.Services.IPowerBIWindowServiceFactory windowServiceFactory, Microsoft.PowerBI.Client.Windows.Services.IUIBlockingService uiBlockingService, Microsoft.PowerBI.Client.Windows.Diagnostics.IDiagnosticInformationService diagnosticsInfoService, Microsoft.PowerBI.Client.Shared.ISystemEnvironment systemEnvironment, Microsoft.PowerBI.Client.Windows.Services.IEventAggregationService eventAggregationService)
Stack Trace:
Microsoft.Practices.Unity.ResolutionFailedException
   at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
   at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
   at Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T](IUnityContainer container, ResolverOverride[] overrides)
   at Microsoft.Mashup.Host.Document.DependencyInjectionService.Resolve[T](String name)
   at Microsoft.PowerBI.Client.Program.<>c__DisplayClass6_0.<RunApplication>b__0()
   at Microsoft.PowerBI.Client.Windows.IExceptionHandlerExtensions.<>c__DisplayClass3_0.<HandleExceptionsWithNestedTasks>b__0()
   at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
Stack Trace Message:
Resolution of the dependency failed, type = "Microsoft.PowerBI.Client.Windows.MainForm", name = "(none)".
Exception occurred while: Calling constructor Microsoft.PowerBI.Client.Windows.MainForm(Microsoft.Mashup.Client.UI.Shared.ILegacyUIHost uiHost, Microsoft.PowerBI.Client.Shared.IPowerBISettings powerBISettings, Microsoft.PowerBI.Client.Windows.IBrowserFactory browserFactory, Microsoft.PowerBI.Client.Windows.Services.IPowerBITelemetryService telemetryService, Microsoft.PowerBI.Client.Windows.Services.IPowerBIWindowServiceFactory windowServiceFactory, Microsoft.PowerBI.Client.Windows.Services.IUIBlockingService uiBlockingService, Microsoft.PowerBI.Client.Windows.Diagnostics.IDiagnosticInformationService diagnosticsInfoService, Microsoft.PowerBI.Client.Shared.ISystemEnvironment systemEnvironment, Microsoft.PowerBI.Client.Windows.Services.IEventAggregationService eventAggregationService).
Exception is: FileNotFoundException - Could not load file or assembly 'System.ComponentModel.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
-----------------------------------------------
At the time of the exception, the container was:

Resolving Microsoft.PowerBI.Client.Windows.MainForm,(none)
  Calling constructor Microsoft.PowerBI.Client.Windows.MainForm(Microsoft.Mashup.Client.UI.Shared.ILegacyUIHost uiHost, Microsoft.PowerBI.Client.Shared.IPowerBISettings powerBISettings, Microsoft.PowerBI.Client.Windows.IBrowserFactory browserFactory, Microsoft.PowerBI.Client.Windows.Services.IPowerBITelemetryService telemetryService, Microsoft.PowerBI.Client.Windows.Services.IPowerBIWindowServiceFactory windowServiceFactory, Microsoft.PowerBI.Client.Windows.Services.IUIBlockingService uiBlockingService, Microsoft.PowerBI.Client.Windows.Diagnostics.IDiagnosticInformationService diagnosticsInfoService, Microsoft.PowerBI.Client.Shared.ISystemEnvironment systemEnvironment, Microsoft.PowerBI.Client.Windows.Services.IEventAggregationService eventAggregationService)

Invocation Stack Trace:
   at Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace()
   at Microsoft.Mashup.Client.UI.Shared.StackTraceInfo..ctor(String exceptionStackTrace, String invocationStackTrace, String exceptionMessage)
   at Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.GetStackTraceInfo(Exception e)
   at Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture)
   at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass14_0.<HandleException>b__0()
   at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.HandleException(Exception e)
   at Microsoft.PowerBI.Client.PowerBIUnexpectedExceptionHandler.HandleException(Exception e)
   at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
   at Microsoft.PowerBI.Client.Program.RunApplication(String[] args)
   at Microsoft.PowerBI.Client.Program.Main(String[] args)

PowerBINonFatalError:
{"AppName":"PBIDesktop","AppVersion":"2.121.644.0","ModuleName":"Microsoft.PowerBI.Client.Windows.dll","Component":"Microsoft.PowerBI.Client.Windows.WebView2.WebView2BrowserWrapper","Error":"System.IO.FileNotFoundException","MethodDef":".ctor","ErrorOffset":"-1","ErrorCode":""}

InnerException0.Stack Trace Message:
Could not load file or assembly 'System.ComponentModel.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

InnerException0.Stack Trace:
   at Microsoft.PowerBI.Client.Windows.WebView2.WebView2BrowserWrapper..ctor(Form form, String url, IBrowserHost host, IPowerBISettings settings, IPowerBITelemetryService telemetryService, ISystemEnvironment systemEnvironment, IExceptionHandler exceptionHandler, IWebView2VersionUtils webView2VersionUtils, String name)
   at Microsoft.PowerBI.Client.Windows.WebView2.WebView2BrowserFactory.CreateBrowser(Form owner, String url, IExceptionHandler exceptionHandler, IBrowserHost host, String name, Boolean canNavigateAfterLoad)
   at Microsoft.PowerBI.Client.Windows.Views.ReportView.CreateBrowserControl(Form form, IBrowserHost host, IExceptionHandler exceptionHandler, IBrowserFactory browserFactory)
   at Microsoft.PowerBI.Client.Windows.Views.ReportView..ctor(Form form, IBrowserHost host, ILegacyUIHost uiHost, IPowerBIWindowService windowService, IExceptionHandler exceptionHandler, IEventAggregationService eventAggregationService, IFeatureSwitchManager featureSwitchManager, IPowerBITelemetryService telemetryService, IApplicationCommands applicationCommands, IBrowserFactory browserFactory)
   at Microsoft.PowerBI.Client.Windows.MainForm.CreateReportView()
   at Microsoft.PowerBI.Client.Windows.MainForm.CreateViews(Int32 priority)
   at Microsoft.PowerBI.Client.Windows.MainForm.InitializeViews()
   at Microsoft.PowerBI.Client.Windows.MainForm..ctor(ILegacyUIHost uiHost, IPowerBISettings powerBISettings, IBrowserFactory browserFactory, IPowerBITelemetryService telemetryService, IPowerBIWindowServiceFactory windowServiceFactory, IUIBlockingService uiBlockingService, IDiagnosticInformationService diagnosticsInfoService, ISystemEnvironment systemEnvironment, IEventAggregationService eventAggregationService)
   at BuildUp_Microsoft.PowerBI.Client.Windows.MainForm(IBuilderContext )
   at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
   at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)

InnerException0.Invocation Stack Trace:
   at Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace()
   at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo.GetFeedbackValuesFromException(Exception e, String prefix)
   at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo.GetFeedbackValuesFromInnerExceptions(Exception e, Int32 depth)
   at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo.CreateAdditionalErrorInfo(Exception e)
   at Microsoft.Mashup.Client.UI.Shared.FeedbackErrorInfo..ctor(String message, Exception exception, Nullable`1 stackTraceInfo, String messageDetail)
   at Microsoft.PowerBI.Client.Windows.Telemetry.PowerBIUserFeedbackServices.ReportException(IWindowHandle activeWindow, IUIHost uiHost, FeedbackPackageInfo feedbackPackageInfo, Exception e, Boolean useGDICapture)
   at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.<>c__DisplayClass14_0.<HandleException>b__0()
   at Microsoft.Mashup.Client.UI.Shared.UnexpectedExceptionHandler.HandleException(Exception e)
   at Microsoft.PowerBI.Client.PowerBIUnexpectedExceptionHandler.HandleException(Exception e)
   at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action)
   at Microsoft.PowerBI.Client.Program.RunApplication(String[] args)
   at Microsoft.PowerBI.Client.Program.Main(String[] args)

PowerBIUserFeedbackServices_IsReported:
True

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.