pnp / pnpjs

Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
https://pnp.github.io/pnpjs/
Other
742 stars 302 forks source link

Forbidden (403) when creating a new ClientSidePage #2971

Closed tpf89 closed 3 months ago

tpf89 commented 4 months ago

What version of PnPjs library you are using

3.x

Minor Version Number

24.0

Target environment

SharePoint Framework

Additional environment details

Using normal SPFx user-scoped authentication via my ListViewCommandSetContext. this.sp = spfi().using(SPFx(context));

SPFx Version: 1.18.2

Question/Request

I want to create a copy of an already existing ClientSidePage in SitePages via

await sourceFile.copyByPath(targetAbsolutePath, false);

It works perfectly on my dev tenant, but fails in production:

POST https://TENANT.sharepoint.com/sites/SITECOLLECTION/_api/SP.MoveCopyUtil.CopyFileByPath(overwrite=@a1)?@a1=false 403 (Forbidden)

X-Msdavext_error: 917656; Access Denied. Before opening files in this location, you must first add the web site to your trusted site list, browse to the web site, and select the option to login automatically.

This is very weird, because we tried it with library owners AND SharePoint admin accounts. I've found this (https://github.com/pnp/pnpjs/issues/2552) issue, but I don't think it applies in this case, does it?

bcameron1231 commented 3 months ago

Hi, given that it works in one tenant but not the production tenant, combined with the error that that is happening. I would definitely double check to confirm the access is properly done.

bcameron1231 commented 3 months ago

Closing this due to inactivity. If you continue to have issues please open a new issue, link to this issue, and provide any additional details available. Thanks!

github-actions[bot] commented 3 months ago

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.