https://github.com/cern/msgraph-poll-discourse-plugin
Discourse plugin to enable polling emails usign Microsoft Graph API
https://github.com/cern/msgraph-poll-discourse-plugin
Last synced: 12 months ago
JSON representation
Discourse plugin to enable polling emails usign Microsoft Graph API
- Host: GitHub
- URL: https://github.com/cern/msgraph-poll-discourse-plugin
- Owner: CERN
- License: mit
- Created: 2023-05-22T09:15:57.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-11-10T15:21:14.000Z (over 2 years ago)
- Last Synced: 2025-06-05T23:07:56.193Z (about 1 year ago)
- Language: Ruby
- Size: 17.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# msgraph-poll-discourse-plugin
Discourse plugin to enable polling emails usign Microsoft Graph API
## Prerequisites
- Have an application on your Azure Tenant with delegated permissions for `Mail.ReadWrite`.
- Get a refresh token for the application with permissions to the mailbox used for the poll feature.
## Get the refresh token
The easiest way to get a refresh token is to use the Device Code authorization flow ().
```bash
TENANT_ID=""
CLIENT_ID=""
curl --request POST \
--url https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/devicecode \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data client_id=${CLIENT_ID} \
--data 'scope=mail.readwrite offline_access'
```
This request returns a JSON, from this we need the `user_code` and the `device_code`.
Open and login with the mailbox you want to use for the poll feature, inserting the `user_code` when requested.
After the login is successful:
```bash
curl --request POST \
--url https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=urn:ietf:params:oauth:grant-type:device_code \
--data client_id=${CLIENT_ID} \
--data device_code=
```
This request returns a JSON with the `refresh_token`.
## SiteSettings
It is possible to configure this plugin using the following SiteSettings:
- `msgraph_polling_enabled`: `true` if the plugin is enabled
- `msgraph_polling_mailbox`: the mailbox to use for the poll feature. It has to be the same you've used to retrieve when retrieving refresh token
- `msgraph_polling_client_id`: the application id of the Azure application. It has to be the same to the one you've used when retrieving the refresh token
- `msgraph_polling_tenant_id`: the tenant ID of your Azure tenant. It has to be the same to the one you've used when retrieving the refresh token
- `msgraph_polling_oauth2_refresh_token`: the refresh token previously generated.
The polling period is the same to the pop3 polling feature present in Discourse core.
## Install
Follow the official guide from Discourse: