App-Only is currently not supported, unless you provide a Microsoft Graph Access Token

New Contributor

Hi,

 

I am trying to execute a site creation using Pnp.Core.

 

var clientContext = new ClientContext(tenantAdminSiteUrl);
TeamSiteCollectionCreationInformation modernteamSiteInfo = new TeamSiteCollectionCreationInformation
                    {
                        Description = siteDescription,
                        DisplayName = siteTitle,
                        Alias = siteUrl,
                        IsPublic = true,
                        Lcid = (uint)lcid,
                    };
var createModernSite = await clientContext.CreateSiteAsync(modernteamSiteInfo);

 Then, I got this error message:

App-Only is currently not supported, unless you provide a Microsoft Graph Access Token.. StackTrace:    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)

 

How can I use that method correctly? The clientcontext how should be initiated?

Thanks

 

Jose Luis 

 

0 Replies