'How to connect RStudio using Shiny to Microsoft 365

I have a lot of googlesheets that i write in and out from using R. We are merging our sheets into Office online(365). How can i connect to the online microsoft services (365) from R, especially Excel. I currently use library(googlesheets) to connect via R. I will also in instances write some of the current googlesheet data out to the Shiny server using R. I'm looking for some advice and can this be done. Thanks



Solution 1:[1]

You can use the AzureGraph R package by Microsoft (documentation) to get a token via your active directory. Then use the Graph API (documentation) with the call_graph_url function from AzureGraph.

I had issues downloading via the API call, so I used the httr GET function and readxl package once I was able to find the graph download URL:

GET(item[["@microsoft.graph.downloadUrl"]], write_disk(tf <- tempfile(fileext = ".xlsx")))

df <- read_excel(tf)

Solution 2:[2]

Per 2022, there is a new (official) package in play that will suit your needs:

https://github.com/Azure/Microsoft365R

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dvisger
Solution 2 Henrik