grafap
grafap is a Python package for interacting with the Microsoft Graph API and the Sharepoint REST API. Primarily common functions with regards to sharepoint lists. Creating new items, querying lists, etc.
Usage
from grafap import GrafapClient
client = GrafapClient(
tenant_id="...",
client_id="...",
client_secret="...",
)
# Or just use convenience func to pull from expected env vars
# if already loaded
client = GrafapClient.from_env()
# async
sites = await client.sites_return()
# sync
sites = client.sync.sites_return()
Can run untit tests with uv run pytest tests -v when in the project root. Integration tests require real Graph API credentials and network access, so they are marked with @pytest.mark.integration and can be run separately with uv run pytest tests -v -m integration.
Configuration
Several parameters are required for grafap client instantiation. Most of the endpoints in grafap are just using the standard Microsoft Graph API which only requires a client ID and secret.
The Sharepoint REST API, however requires using a client certificate. The Sharepoint REST API is currently only used for the following functions (that don't have an equivalent in the Microsoft Graph API). If you're not using them, then you don't need the certificate or the other vars in the Sharepoint REST API table.
- "ensuring" a user in a sharepoint site.
- downloading an attachment from a sharepoint list item
MS Graph Vars
| Env Variable | Description |
|---|---|
| GRAPH_LOGIN_BASE_URL | Should be https://login.microsoftonline.com/ |
| GRAPH_BASE_URL | Should be https://graph.microsoft.com/v1.0/sites/ |
| GRAPH_TENANT_ID | Tenant ID from app registration created in Azure. |
| GRAPH_CLIENT_ID | Client ID from app registration created in Azure. |
| GRAPH_CLIENT_SECRET | Client secret from app registration created in Azure. |
| GRAPH_GRANT_TYPE | Should be 'client_credentials' |
| GRAPH_SCOPES | Should typically be https://graph.microsoft.com/.default unless using more fine-grained permissions. |
Sharepoint Rest API Vars
| Env Variable | Description |
|---|---|
| SP_SITE | Base Site URL you're interacting with. Should be https://DOMAIN.sharepoint.com/ |
| SP_SCOPES | Scopes for sharepoint rest API. Should look like <https://{tenant name}.sharepoint.com/.default> |
| SP_LOGIN_BASE_URL | Should be https://login.microsoftonline.com/ |
| SP_TENANT_ID | Tenant ID from app registration created in Azure. |
| SP_CLIENT_ID | Client ID from app registration created in Azure. |
| SP_GRANT_TYPE | client_credentials |
| SP_CERTIFICATE_PATH | Path to .pfx file |
| SP_CERTIFICATE_PASSWORD | Password for the .pfx file. |
Metadata
Release files for grafap 2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| grafap-2.1.tar.gz | 11.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| grafap-2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.4 kB
Release files / grafap-2.1.tar.gz
| Download URL | grafap-2.1.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0681e356f366f358e309cfe930feecedd6aca30e2702dfa0bf865011850328cf
|
|
BLAKE2b-256 checksum How to use checksums |
df7efc0a4df58a4a3c6fb7b741d7daa452ab4f9a68680cb672743e4d8177c8d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / grafap-2.1-py3-none-any.whl
| Download URL | grafap-2.1-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1b88323221c91e508863b667c818c83ed202fcd5b4ffc2cd42c507557a8aca3
|
|
BLAKE2b-256 checksum How to use checksums |
2517e9a07e9faf9e3334ab5819cc1f8c37462283727da048d9b3e5058bd59511
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|