-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.Rmd
92 lines (65 loc) · 2.71 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
output:
md_document:
variant: markdown_github
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# msgraphr
> NOTE: This package is quite raw. I am not currently using Office 365
and cannot develop or debug features apart from the general
MS Graph interface. Pull Requests are **most** welcome!
**msgraphr** is a minimal R wrapper of the SharePoint Online (Office 365)
APIs, aiming to allow R users to pull down list information as dataframes for
local analysis. Liberate your data from SharePoint!
## Installation
`devtools::install_github("davidski/msgraphr")`
## Authentication
* Create an application at https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade with the following fields:
+ `Name` Name of your MS Graph app e.g. `msgraphr_query`.
+ Under `Redirect URIs` at a web link pointing to `http://localhost:1410`.
+ Take note of the `Application Id`, this will be your `client_id`.
+ Under `Certificates & Secrets` generate an application secret and note the
value for use as the `Client Secret`.
+ Add a Platform and select `Web`.
+ `Allow Implicit Flow`: Unchecked
+ Under API Permissions, alter the Microsoft Graph permissions to
specify the scopes for which you wish to grant access.
* (OPTIONAL, BUT RECOMMENDED) Set the `MSGRAPH_PAT` environment variable to a
file location on disk for `msgraphr` to cache the Oauth2.0 token. Defaults
to the current working directory.
* To perform the initial authentication.
```
msgraph_auth(client_id = "REDACTED",
client_secret = "REDACTED" )
```
### Scope used
* `msgraphr` requests the following access scopes:
+ `User` and `Sites.Read.All` for SharePoint online read access
+ `offline_user` so that tokens may be auto-refreshed without further user action
## Usage
```{r example, eval = FALSE}
library(tidyverse)
library(msgraphr)
# auth
token <- msgraph_auth()
# list all the sites to which you have accesss
get_sites(search = "", token) %>% head(1) %>% pull(id) -> my_site
# list all the lists on that site
get_lists(site_id = my_site, token) %>% head(1) %>% pull(id) -> my_list
# fetch all the entries on that list
get_list_entries(site_id = my_site, list_id = my_list, token)
# go forth and do amazing things!
```
## References
See the [MS Graph](https://developer.microsoft.com/en-us/graph/docs/concepts/overview) API documentation.
## Contributing
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
## License
The [MIT License](LICENSE) applies.