koltyakov / gosip

⚡️ SharePoint SDK for Go
https://go.spflow.com
MIT License
145 stars 33 forks source link

Uploading files using Addin auth is not allowed to place files into "shared documents" #56

Closed jhoelzel closed 1 year ago

jhoelzel commented 1 year ago

First of thank you for this libary and everything you do for it, it will be perfect for us to sync our scanned documents to the cloud using older scaners, where we can deploy the go code directly.

Describe the bug Using Addin configuration i am trying to uplooad files to a specifically created sharepoint for scanned documents. Iam using the sample app here:

https://github.com/koltyakov/gosip-sandbox/tree/master/samples/spsync

and am using the permissions listed in the documentation: https://go.spflow.com/auth/strategies/addin/configuration

However i am unable to upload files to the shared documents folder. Once i tune the error logging of the example the error i recieve is this:

2023/03/27 13:31:13 /var/workspace/3/watched/peter/a copy.txt: unable to request api: 403 Forbidden :: {"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"de-DE","value":"Zugriff verweigert."}}}

Versions Current version of office 365

To Reproduce Use sample application, give (site scoped) sharepoint permissions and run the sync. Also change line 179 in the sample to return err instead of nil

Expected behavior As i can upoad to Siteassets i would like to be able to upload to shared documents

Additional context I would like to use the documents folder as i want it to be seen easily by users, every user shall have his folder protected and thus easy acces is imperative for us. If there is a better way to do this, i am all ears too

jhoelzel commented 1 year ago

If i create a new Document library it works without issue. It might be some internal thing from MS

koltyakov commented 1 year ago

Hey @jhoelzel

It could be connected with this https://learn.microsoft.com/en-us/sharepoint/allow-or-prevent-custom-script

jhoelzel commented 1 year ago

Dear @koltyakov ,

thank you for your help, but " -DenyAddAndCustomizePages 0 " did nothing to solve the issue.

However i found the issue. Its the naming and acces of the API.

Im attending to a german client with my interface set to english where the folder is called "documents" however the api only recognizes it as "Freigegebene Dokumente" and otherwise you will receive a permission denied error.

This seems to be a hack on the side of MS itself and i have no idea why they would do that.

image

image

Once more thank you for your assistance and providing this libary!

koltyakov commented 1 year ago

It's usually better getting lists/doc libs by path. E.g.:

// The recommended way of getting lists is by using their relative URIs
// can be a short form without full web relative URL prefix
list := sp.Web().GetList("MyLibrary") // where `/sites/site/**MyLibrary**`

// other common but less recommended way of getting a list is
// list := sp.Web().Lists().GetByTitle("My Library")