18 lines
		
	
	
		
			405 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			405 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from fastapi import APIRouter, Depends
 | |
| from typing import Annotated, Union
 | |
| import secrets
 | |
| from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
 | |
| 
 | |
| 
 | |
| auth = APIRouter()
 | |
| 
 | |
| 
 | |
| @auth.get("/create_secret_key/")
 | |
| async def create_secret_key():
 | |
|     return {"key": secrets.token_hex(32)}
 | |
| 
 | |
| 
 | |
| @auth.post("/token")
 | |
| async def login(form_data: Annotated[OAuth2PasswordRequestForm, Depends()]):
 | |
|     pass
 |