Using Sharepoint with Graph API
Hi,
Is it possible to use the Graph API for Sharepoint? Does ClientContext.with_access_token work to authenticate, and what parts of the Graph API are supported?
Otherwise, is there a plan to add support for Sharepoint Graph API?
I would also be interested in knowing this.
I am moving from basic auth to Azure service principal using certificates and I am having problems (403) with the lib after changing the authentication method to with_client_certificate. I believe that all the permissions were granted to my principal in sharepoint admin, so I am not sure what it's happening. Also, using the same details to authenticate in the MS graph examples works just fine.
@vgrem sorry for pinging you - but can we use graph for sharepoint? Or, would you know by any chance what could cause the error
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://xxxx.sharepoint.com/sites/xxxxx/_api/Web/getFolderByServerRelativeUrl('General')/Folders by only changing the authentication method? Thank you!
I've also switched to Azure service principal and can access token with saml. ClientContext.with_access_token is not working for me. @nmduarte @adambenali Have you guys had any luck on this?
Greetings,
when working with SharePoint API both SharePoint and SharePoint with Microsoft Graph APIs are supported, namely:
- SharePoint API which covers SharePoint 2013 or above and OneDrive for Business via
ClientContextclient - SharePoint with Microsoft Graph API via
GraphClientclient
Get a file properties via SharePoint API
ctx = ClientContext(test_team_site_url).with_credentials(client_credentials)
file_url = 'Shared Documents/Report.xlsx'
file = ctx.web.get_file_by_server_relative_url(file_url).get().execute_query()
Get a file properties via SharePoint API with Microsoft Graph
from office365.graph_client import GraphClient
client = GraphClient(acquire_token_by_client_credentials)
file_path = "Shared Documents/Report.xlsx"
file = client.users[user_id].drive.root.get_by_path(file_path).get().execute_query()
@nmduarte, regarding:
can we use graph for SharePoint
definitely, please refer examples section which demonstrates how to use SharePoint API with Microsoft Graph.
In terms of 403 Client Error: Forbidden error when using with_client_certificate method, perhaps it was similar to this issue, anyway nowadays it has resolved.