How can I access a shared Sharepoint folder from GraphSDK?

Anderson 0 Reputation points
2026-08-07T19:22:42.6766667+00:00

Hi!

So, I'm tasked with implementing a java code (for a web application) that will update some files on sharepoint when the user updates some data.

I have been given access to a folder "https://companyname.sharepoint.com/sites/departmentname/path/to/folder", when it was shared with me, but, otherwise, I don't have much access to the other department's sharepoint.

I have added my application to EntraID with scopes "User.Read" and "Files.SelectedOperations.Selected".

I was able to login and read some graphCliente.me() information. But, so far, I can't figure out how to read the sharepoint folder I'm supposed to manage.

A lot of what I've found says I should provide the driveId for the request. But I can't seem to find it with the level of access I have now.

I have tried adding the permission request from https://learn.microsoft.com/en-us/graph/permissions-selected-overview?tabs=java. But it doesn't work: "Access denied".

I've also tried to adapt it by changing the request line to include a getByPathWithPath("path/to/folder"), but still no luck. (Fails with a 400 Bad Request.)

Permission result = graphClient.sites().bySiteId("{site-id}").getByPathWithPath("path/to/folder").permissions().post(permission);

Does anyone know what's missing/wrong here?

Also, I there was a way to log complete requests/responses, that might help.

Thanks.

And sorry, if this is a dumb question, but I'm not used to MS-specific stuff, and this all still seems a bit confusing.

Microsoft Security | Microsoft Graph
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.