mirror of
https://github.com/MarkParker5/STARK.git
synced 2024-11-24 08:12:13 +02:00
save tokens endpoint
This commit is contained in:
parent
76b06c7344
commit
fae0310445
@ -38,3 +38,9 @@ class HubManager:
|
||||
|
||||
def wifi(self, ssid: str, password: str):
|
||||
WiFi.save_and_connect(ssid, password)
|
||||
|
||||
def set_tokens(tokens_pair: schemas.TokensPair):
|
||||
with open(f'{path}/{resources}/access_token.txt', 'w') as f:
|
||||
f.write(tokens_pair.access_token)
|
||||
with open(f'{path}/{resources}/refresh_token.txt', 'w') as f:
|
||||
f.write(tokens_pair.refresh_token)
|
||||
|
@ -2,7 +2,7 @@ from uuid import UUID
|
||||
from fastapi import APIRouter, Depends
|
||||
import Controls.API.exceptions
|
||||
from .HubManager import HubManager
|
||||
from .schemas import Hub, PatchHub
|
||||
from .schemas import Hub, PatchHub, TokensPair
|
||||
|
||||
|
||||
router = APIRouter(
|
||||
@ -25,3 +25,7 @@ async def hub_patch(hub: PatchHub, manager: HubManager = Depends()):
|
||||
@router.post('/wifi')
|
||||
async def hub_wifi(ssid: str, password: str, manager: HubManager = Depends()):
|
||||
manager.wifi(ssid, password)
|
||||
|
||||
@router.post('set_tokens')
|
||||
async def set_tokens(tokens: TokensPair):
|
||||
manager.save_tokens(tokens)
|
||||
|
@ -12,3 +12,7 @@ class Hub(BaseModel):
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
class TokensPair(BaseModel):
|
||||
access_token: str
|
||||
refresh_token: str
|
||||
|
Loading…
Reference in New Issue
Block a user