mirror of
https://github.com/lanqian528/chat2api.git
synced 2026-06-13 21:02:46 +08:00
v1.6.2-beta3 fix bugs
This commit is contained in:
parent
fc2053a5af
commit
36d7567ec9
2
app.py
2
app.py
@ -28,7 +28,7 @@ app.add_middleware(
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token", auto_error=False)
|
||||
|
||||
import mirror.backend
|
||||
import gateway.backend
|
||||
import api.chat2api
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import json
|
||||
import random
|
||||
import re
|
||||
import time
|
||||
|
||||
@ -7,8 +8,9 @@ from fastapi.responses import HTMLResponse, RedirectResponse, Response
|
||||
|
||||
import utils.globals as globals
|
||||
from app import app, templates
|
||||
from mirror.reverseProxy import chatgpt_reverse_proxy
|
||||
from utils.config import enable_gateway
|
||||
from gateway.reverseProxy import chatgpt_reverse_proxy
|
||||
from utils.Client import Client
|
||||
from utils.config import enable_gateway, proxy_url_list
|
||||
|
||||
if enable_gateway:
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
@ -24,6 +26,20 @@ if enable_gateway:
|
||||
return response
|
||||
|
||||
|
||||
@app.post("/auth/refresh")
|
||||
async def refresh(request: Request):
|
||||
res = await request.json()
|
||||
refresh_token = res.get("refresh_token", "")
|
||||
data = {
|
||||
"client_id": "pdlLIX2Y72MIl2rhLhTE9VV9bN905kBh",
|
||||
"grant_type": "refresh_token",
|
||||
"redirect_uri": "com.openai.chat://auth0.openai.com/ios/com.openai.chat/callback",
|
||||
"refresh_token": refresh_token
|
||||
}
|
||||
client = Client(proxy=random.choice(proxy_url_list) if proxy_url_list else None)
|
||||
r = (await client.post("https://auth0.openai.com/oauth/token", json=data, timeout=5)).json()
|
||||
return r
|
||||
|
||||
@app.get("/login", response_class=HTMLResponse)
|
||||
async def login_html(request: Request):
|
||||
response = templates.TemplateResponse("login.html", {"request": request})
|
||||
@ -1 +1 @@
|
||||
1.6.2-beta2
|
||||
1.6.2-beta3
|
||||
Loading…
Reference in New Issue
Block a user