rstudio / pins-r

Pin, discover, and share resources
https://pins.rstudio.com
Other
312 stars 63 forks source link

Sharing a board in Business OneDrive - Recipient not finding the shared folder #588

Closed AkthemRehab closed 1 year ago

AkthemRehab commented 2 years ago

I try to follow the example in the ?board_ms365 . The board is created successfully, but when I try from the same RStudio session to simulate the recipient and run this command:

shared_items <- od$list_shared_items() shared_items ----- returns an empty list list()

as a result the following command:

board_folder <- shared_items$remoteItem[[which(shared_items$name == "myboard")]] --- returns an error: attempt to select less than one element in get1index

Please advice.

juliasilge commented 2 years ago

We can confirm that something is not working as expected. If I write a pin to a OneDrive board:

library(pins)

od <- Microsoft365R::get_personal_onedrive()
#> Loading Microsoft Graph login for tenant 'consumers'
board <- board_ms365(od, "board_to_share_with_michael")
board %>% pin_write(mtcars)
#> Using `name = 'mtcars'`
#> Guessing `type = 'rds'`
#> Creating new version '20220812T161248Z-66143'
#> Writing to pin 'mtcars'

Created on 2022-08-12 by the reprex package (v2.0.1)

And then I go into OneDrive and share the board with @machow, he still cannot read it:

library(pins)

od <- Microsoft365R::get_personal_onedrive()
#> Loading Microsoft Graph login for tenant 'consumers'
board <- board_ms365(od, "board_to_share_with_michael")
board %>% pin_read("mtcars")
#> Error in `abort_pin_missing()`:
#> ! Can't find pin called 'mtcars'
#> ℹ Use `pin_list()` to see all available pins in this board

Created on 2022-08-12 by the reprex package (v2.0.1)

We'll look more into this.

machow commented 2 years ago

Based on the board_ms365 docs, I think we need to use od$list_shared_items() to create a special path to the shared board. But I can't get this to run...

od <- Microsoft365R::get_personal_onedrive()
#> Loading Microsoft Graph login for tenant 'consumers'
#> Access token has expired or is no longer valid; refreshing
od$list_shared_items()
#> Error in `[.data.frame`(df, c("name", "size", "isdir", "remoteItem")): undefined columns selected

Created on 2022-08-12 by the reprex package (v2.0.1)

machow commented 2 years ago

@juliasilge I'm not sure why, but I get this error when I look for shared folders (using Microsoft365R v2.3.4):

od <- Microsoft365R::get_personal_onedrive()
#> Loading Microsoft Graph login for tenant 'consumers'
od$list_shared_items()
#> Error in `[.data.frame`(df, c("name", "size", "isdir", "remoteItem")): undefined columns selected

Created on 2022-08-15 by the reprex package (v2.0.1)

AkthemRehab commented 2 years ago

I recently found myself coming back to this again. Went deeper this time and tried three scenarios, 1 worked while the other 2 remain buggy.

Scenario1: I follow the example code and apply it between 2 Onedrive business users having the same tenant. This works perfectly.

Scenario2: I follow the example code and apply it between 2 Onedrive personal users (hotmail accounts). This does not work. The issue is in the recipient's side code, specifically finding the shared item: od$list_shared_items()

It returns this error: Error in [.data.frame(df, c("name", "size", "isdir", "remoteItem")) : undefined columns selected

This error is returned, while the recipient is able to see the shared folder in the shared with me tab in the personal onedrive web client. trying a workaround from within onedrive, i.e., creating a shortcut of the folder and calling the od$list_items instead lead to finding the folder but fails to provide visibility to its board contents afterwards.

Scenario 3: Sharing from personal onedrive (hotmail) to a business onedrive tenant. The shared item does not appear in the recipient's shared items list and does not show in the recipient's web client shared with me tab.

I hope this helps any of you who are still facing the same issue and that someone can help me make it work for the 2 scenarios that I still did not succeed in making them work.

P.S. I am referring to the example in this documentation: https://pins.rstudio.com/reference/board_ms365.html?q=onedri#null

AkthemRehab commented 2 years ago

I got this while chatting with Microsoft: https://feedbackportal.microsoft.com/feedback/idea/a4b62fc6-d61c-ec11-b6e7-0022481f8914

Based on this, it seems the inter business - personal Onedrive sharing is not working at the moment and, accordingly, I do not expect it to work in r-pins.

Remains the personal ondrive intra transfer which by now I think is a r-pins issue, not a onedrive issue.

juliasilge commented 2 years ago

It looks like the Microsoft365R R package hasn't been worked on in about 6 months, and I heard through the grapevine that the maintainer no longer works at Microsoft. We might need to see what options we have for getting some more info on what is going on here.

hongooi73 commented 1 year ago

Hi there, I'm looking at this issue now. @juliasilge can you email me? Thanks.

hongooi73 commented 1 year ago

Actually, this might be a bug in list_shared_items that's been present from the start 😅

As a workaround, where the example in ?board_ms365 has shared_items <- od$list_shared_items(), use `shared_items <- od$list_shared_items(info="items") and then select the shared object from the list. Something like this:

shared_items <- od$list_shared_items(info="items")
shared_items
board_folder <- shared_items[[X]]  # replace X with the correct entry
board <- board_ms365(od, board_folder)

I'm getting a subsequent 404 error on trying to list items in the board, but that may be a separate issue.

hongooi73 commented 1 year ago

While the "undefined columns selected" fix is simple, I've uncovered a deeper problem with how Microsoft365R works with shared items. Tracking this here: https://github.com/Azure/Microsoft365R/issues/149

hongooi73 commented 1 year ago

I can write to the test board now. If anyone wants to try it out, you can install the dev branch of Azure/Microsoft365R: https://github.com/Azure/Microsoft365R/tree/dev

I haven't got access to Business Onedrive or Sharepoint, so would greatly appreciate someone with these trying out the code.

hongooi73 commented 1 year ago

Can people using Sharepoint/Business Onedrive try using pins with the latest dev version of Microsoft365R? I believe the bugs should be ironed out now.

(This is on the master branch of https://github.com/Azure/Microsoft365R)

hongooi73 commented 1 year ago

Microsoft365R 2.4.0 is now on CRAN, and should hopefully fix this.

juliasilge commented 1 year ago

Wonderful @hongooi73! 🙌 Thank you so much for your work on this. We will close this now and if folks have any related problems in the future, we can open new issues.

github-actions[bot] commented 1 year ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.