MS Graph API Integration¶
Die MORELO Dealer Suite nutzt Microsoft Graph als zentrale Schnittstelle zu Microsoft 365.
Übersicht¶
| Dienst | Graph API | Verwendung |
|---|---|---|
| Bookings | /solutions/bookingBusinesses |
Terminverwaltung |
| Calendar | /me/calendar |
Outlook Kalender |
/me/messages |
E-Mail Versand | |
| Users | /users |
Mitarbeiterverwaltung |
| SharePoint | /sites |
Dokumentenablage |
| Teams | /teams |
Online-Meetings |
Authentifizierung¶
App Registration (Azure AD)¶
# Erforderliche Permissions
- Bookings.ReadWrite.All
- Calendars.ReadWrite
- Mail.Send
- User.Read.All
- Sites.ReadWrite.All
OAuth 2.0 Flow¶
// Token abrufen (Client Credentials)
const tokenResponse = await fetch(
`https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/token`,
{
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
scope: 'https://graph.microsoft.com/.default',
grant_type: 'client_credentials'
})
}
);
const { access_token } = await tokenResponse.json();
SonicJS Integration¶
Route: /api/integrations/msgraph¶
// src/routes/integrations/msgraph.ts
import { Hono } from 'hono';
const app = new Hono();
// Proxy zu MS Graph mit Caching
app.get('/calendar/events', async (c) => {
const cached = await c.env.KV.get('calendar:events', 'json');
if (cached) return c.json(cached);
const token = await getAccessToken(c.env);
const events = await fetch(
'https://graph.microsoft.com/v1.0/me/calendar/events',
{ headers: { Authorization: `Bearer ${token}` } }
).then(r => r.json());
await c.env.KV.put('calendar:events', JSON.stringify(events), {
expirationTtl: 300 // 5 min cache
});
return c.json(events);
});
export default app;
Verwendete Endpoints¶
Bookings (Termine)¶
Siehe: Microsoft Bookings Integration
Calendar (Kalender)¶
# Events abrufen
GET /me/calendar/events
?$top=10
&$orderby=start/dateTime
&$filter=start/dateTime ge '2026-01-15T00:00:00Z'
# Event erstellen
POST /me/calendar/events
{
"subject": "Probefahrt - Hans Mustermann",
"start": { "dateTime": "2026-01-20T10:00:00", "timeZone": "Europe/Berlin" },
"end": { "dateTime": "2026-01-20T12:00:00", "timeZone": "Europe/Berlin" },
"location": { "displayName": "MORELO Händler" }
}
Mail (E-Mail)¶
# E-Mail senden
POST /me/sendMail
{
"message": {
"subject": "Ihre Probefahrt-Bestätigung",
"body": { "contentType": "HTML", "content": "<html>...</html>" },
"toRecipients": [
{ "emailAddress": { "address": "kunde@email.de" } }
]
}
}
Rate Limits¶
| Ressource | Limit |
|---|---|
| Alle Endpoints | 10.000 req/10min pro App |
| Mail senden | 10.000/Tag pro Mailbox |
| Delta queries | 5.000/10min |