Azure / Microsoft365R

R SDK for interacting with Microsoft 365 APIs
Other
308 stars 42 forks source link

Is it expected that 'get_sharepoint_site' requires further admin permissions unlike the depracated 'sharepoint_site'? #155

Closed jwolfc closed 1 year ago

jwolfc commented 1 year ago

'sharepoint_site' is deprecated but works for me because does not require further admin permissions unlike 'get_sharepoint_site'. 'sharepoint_site' will still be available in the future? Is this the expected behavior, why?

hongooi73 commented 1 year ago

sharepoint_site just calls get_sharepoint_site under the hood, so it's all the same code ultimately. However, sharepoint_site uses different default permissions, as you can see by the signatures:

sharepoint_site <- function(site_url=NULL, site_id=NULL,
                            tenant=Sys.getenv("CLIMICROSOFT365_TENANT", "common"),
                            app=Sys.getenv("CLIMICROSOFT365_AADAPPID"),
                            scopes=".default",
                            ...)
# ...

get_sharepoint_site <- function(site_name=NULL, site_url=NULL, site_id=NULL,
                                tenant=Sys.getenv("CLIMICROSOFT365_TENANT", "common"),
                                app=Sys.getenv("CLIMICROSOFT365_AADAPPID"),
                                scopes=c("Group.ReadWrite.All", "Directory.Read.All",
                                         "Sites.ReadWrite.All", "Sites.Manage.All"),
                                token=NULL,
                                ...)
# ...

So to replicate the behaviour of the old function, pass scopes=".default" to get_sharepoint_site. Note that this will depend on the default permissions for the app ID you use, but if it worked before, it should continue to work.

jwolfc commented 1 year ago

Thank you for your answer. But get_sharepoint_sitestill does not work with scopes=".default", the error now is "Error: Site ... not found". I passed the same arguments in sharepoint_site and the deprecated command works.

I ran list_sharepoint_sites(tenant = "...", scopes = ".default") and it listed the sharepoint sites that I created but not the one I have access to that I required.