🔌 Naturstrom Proxy API

Proxy-Server für sicheren Zugriff auf die Exnaton Public API

ONLINE Server läuft auf: https://naturstrom.openwb.de

📋 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:

🧪 API Testing

1. OAuth Flow testen

2. API Proxy testen

📖 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

  1. Konfigurieren Sie Ihre Domain in config.php
  2. Konfigurieren Sie die Proxy-URL in config.php
  3. Stellen Sie sicher, dass Sessions funktionieren (session_start)
  4. Richten Sie die Redirect-URL in der Exnaton/Naturstrom OAuth-Konfiguration ein