pnp / pnp/pnpframework

TeamSiteCollectionCreationInformation creation failed with GetACSAppOnlyContext

Open
#723 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
259
Forks
161
Avg merge
10h 33m
Merged PRs (30d)
1

Description

(I saw similar issues created but they were closed without any mitigation)

I'm facing an issue when trying to create TeamSite with PnP using the code below:

using (ClientContext cc = new AuthenticationManager().GetACSAppOnlyContext(siteUrl, clientID, clientSecret))
{
    var result = await cc.CreateSiteAsync(new TeamSiteCollectionCreationInformation
    {
        Alias = "mymodernteamsite", // Mandatory
        DisplayName = "displayName", // Mandatory
        Description = "description", // Optional
        IsPublic = true, // Optional, default true
    });
}

Exception:
System.Exception: App-Only is currently not supported, unless you provide a Microsoft Graph Access Token. at PnP.Framework.Sites.SiteCollection.CreateAsync(ClientContext clientContext, TeamSiteCollectionCreationInformation siteCollectionCreationInformation, Int32 delayAfterCreation, Int32 maxRetryCount, Int32 retryDelay, Boolean noWait, String graphAccessToken, AzureEnvironment azureEnvironment) at Microsoft.SharePoint.Client.ClientContextExtensions.CreateSiteAsync(ClientContext clientContext, TeamSiteCollectionCreationInformation siteCollectionCreationInformation) at VnextApi.SharePointUtils.CreateSite(String siteName) in C:\Users\ayelasr\source\repos\VnextApi\VnextApi\SharePointUtils.cs:line 86 at VnextApi.Controllers.ProvisioningController.CreateSite() in C:\Users\ayelasr\source\repos\VnextApi\VnextApi\Controllers\ProvisioningController.cs:line 49 at lambda_method(Closure , Object )

Version:
"PnP.Framework" Version="1.9.0"
netcoreapp3.1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at PnP.Framework.Sites.SiteCollection.CreateAsync, where the exception is raised, and trace the call from ClientContextExtensions.CreateSiteAsync to SharePointUtils.cs line 86. Compare the GetACSAppOnlyContext authentication with the site-creation requirements; done means the supported path or a concrete mitigation is established for this failing scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
authentication, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.