microsoft / BCApps

Repository for collaboration on Microsoft Dynamics 365 Business Central applications.
https://microsoft.github.io/BCApps/
MIT License
299 stars 143 forks source link

SharePoint Authorization integration can not authorize with Client Credentials #1602

Open KaiFroehlich opened 2 months ago

KaiFroehlich commented 2 months ago

Please include the following with each issue:

1. Describe the bug After using codeunit 9142 "SharePoint Auth." to initialize my Codeunit "SharePoint Client" with ClientCredentials (AadTenantId, ClientId, Certificate, CertificatePassword & Scope), when using said SharePoint Client to connect to SharePoint, a .NET error is thrown: "A call to Microsoft.Dynamics.Nav.Runtime.ALAzureAdCodeGrantFlow.ALAcquireApplicationTokensWithCertificate failed with this message: The specified network password is not correct." All Input Parameters have been checked, and the Client has full delegated and application site access to SharePoint: image

2. To Reproduce Steps to reproduce the behavior:

  1. Create a Application Registration in Entra with Access Rights to SharePoint and a Certificate to authenticate against it
  2. Try to initialize a SharePoint Client for a given SharePoint Site of the tenant with the resulting ClientId, CertificateText and CertificateSecret
  3. Try to use the SharePoint Client to do anything in SharePoint
    local procedure CreateTestFolder()
    var
        SharePointAuth: Codeunit "SharePoint Auth.";
        SharePointClient: Codeunit "SharePoint Client";
        TempSharepointFolder: Record "SharePoint Folder" temporary;
    begin
        SharePointClient.Initialize(SiteURL, SharePointAuth.CreateClientCredentials(TenantId, ClientId, CertificateText, CertificateSecret, Scope));
        SharepointClient.CreateFolder(FolderPath, TempSharepointFolder);
    end;

3. Expected behavior Authorization against SharePoint is granted, in case of CreateTestFolder(), the desired folder is created in the SharePoint Site

4. Actual behavior When trying to use the SharePoint Client (for example, to create a folder), a .NET error is thrown: "A call to Microsoft.Dynamics.Nav.Runtime.ALAzureAdCodeGrantFlow.ALAcquireApplicationTokensWithCertificate failed with this message: The specified network password is not correct."

5. Versions:

JesperSchulz commented 2 weeks ago

@KaiFroehlich, your issue was transferred here to BCApps, where you can create PRs to address the issues you've found yourself. Is that something you'd be interested in, or do you want Microsoft to look into the issue for you? In that case, you need to create a support case.