📋 API Endpoints
POST OAuth Authentifizierung starten
URL: https://naturstrom.openwb.de/naturstrom-auth.php
Beschreibung: Startet den OAuth-Flow und gibt eine Authorization-URL zurück
Response:
{
"success": true,
"authorizationUrl": "https://naturstrom-staging.powerquartier.de/api/oauth2/auth?...",
"state": "generated-state-token",
"message": "Please redirect the user to the provided authorization URL"
}
GET OAuth Callback
URL: https://naturstrom.openwb.de/naturstrom-callback.php
Beschreibung: Wird automatisch nach erfolgreicher OAuth-Anmeldung aufgerufen und tauscht den Code gegen Token.
Im Testmodus kann der Redirect auch über /naturstrom-auth.php laufen und wird intern weitergeleitet.
GET API Proxy
URL: https://naturstrom.openwb.de/naturstrom-proxy.php/{endpoint}
Beschreibung: Proxy für Exnaton Public API Aufrufe mit automatischer Authentifizierung
Unterstützte Endpoints:
/accounts - Accounts auflisten
/accounts/{id}/base-price/current - Aktueller Basispreis
/accounts/{id}/rate/current - Aktueller Energiepreis
/accounts/{id}/rate - Rate-Zeitreihe
📖 Integration Guide
Frontend Integration
// 1. OAuth Flow starten
const response = await fetch('https://naturstrom.openwb.de/naturstrom-auth.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({})
});
const data = await response.json();
if (data.success) {
// Benutzer zur Authorization URL weiterleiten
window.open(data.authorizationUrl, '_blank');
}
// 2. API Aufrufe über Proxy
const rateResponse = await fetch('https://naturstrom.openwb.de/naturstrom-proxy.php/accounts/ACCOUNT_ID/rate/current');
const rate = await rateResponse.json();
⚙️ Setup Instructions
- Konfigurieren Sie Ihre Domain in
config.php
- Konfigurieren Sie die Proxy-URL in
config.php
- Stellen Sie sicher, dass Sessions funktionieren (session_start)
- Richten Sie die Redirect-URL in der Exnaton/Naturstrom OAuth-Konfiguration ein