|
|
@@ -9,7 +9,7 @@ from fastapi.responses import FileResponse
|
|
|
from fastapi import FastAPI, Depends, HTTPException, Form
|
|
|
import httpx
|
|
|
import os
|
|
|
-from db.user import UserOAuthToken
|
|
|
+# from db.user import UserOAuthToken
|
|
|
from config import HOST, PORT
|
|
|
|
|
|
app = FastAPI()
|
|
|
@@ -43,18 +43,36 @@ async def get_access_token(request: Request):
|
|
|
|
|
|
if response.status_code != 200:
|
|
|
raise HTTPException(status_code=response.status_code, detail=response.text)
|
|
|
-
|
|
|
+ '''
|
|
|
+ {
|
|
|
+ "data": {
|
|
|
+ "access_token": "act.f7094fbffab2ecbfc45e9af9c32bc241oYdckvBKe82BPx8T******",
|
|
|
+ "captcha": "",
|
|
|
+ "desc_url": "",
|
|
|
+ "description": "",
|
|
|
+ "error_code": 0,
|
|
|
+ "expires_in": 1296000,
|
|
|
+ "log_id": "20230525105733ED3ED7AC56A******",
|
|
|
+ "open_id": "b9b71865-7fea-44cc-******",
|
|
|
+ "refresh_expires_in": 2592000,
|
|
|
+ "refresh_token": "rft.713900b74edde9f30ec4e246b706da30t******",
|
|
|
+ "scope": "user_info"
|
|
|
+ },
|
|
|
+ "message": "success"
|
|
|
+ }
|
|
|
+ '''
|
|
|
data = response.json()["data"]
|
|
|
|
|
|
print(data)
|
|
|
-
|
|
|
+ # magong_user = UserOAuthToken(access_token=data['access_token'], open_id=data['open_id'])
|
|
|
return {"message": "Access token stored successfully"}
|
|
|
|
|
|
@app.get("/verify_callback")
|
|
|
async def verify_callback(request: Request):
|
|
|
# 打印请求方法
|
|
|
print(f"Method: {request.method}")
|
|
|
-
|
|
|
+ # open-douyin.magong.site/verify_callback?code=676a1101ea02bc5dTaUVtKg8c5enYaGqB4dT&state=&scopes=user_info,trial.whitelist
|
|
|
+ print(request.url)
|
|
|
# 打印请求头
|
|
|
print(f"Headers:")
|
|
|
for key, value in request.headers.items():
|
|
|
@@ -67,7 +85,11 @@ async def verify_callback(request: Request):
|
|
|
return HTMLResponse("<h1>Callback Received! Verification Successful.</h1>")
|
|
|
|
|
|
def main():
|
|
|
- uvicorn.run(app, host=HOST, port=PORT, log_level="info")
|
|
|
+ print(f"https://open-douyin-cf.magong.site 公网代理地址,cloudflare dns proxy ,由 caddy 转发到 8600 端口")
|
|
|
+ print(f"https://open-douyin-wk.magong.site 公网代理地址,cloudflare workers 转发到 8600 端口")
|
|
|
+ print(f"http://sv-v2.magong.site:{PORT} ⭐ 推荐,仅支持 ipv6 ,直连、满速、无延迟。缺点是不支持 https 协议,因为不经过 Caddy 代理,直达 Fastapi 没有配置 https")
|
|
|
+ print(f"https://open-douyin.magong.site 内网穿透隧道,cloudflare tunnel ,经常访问不了")
|
|
|
+ uvicorn.run(app, host=None, port=PORT, log_level="info")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
main()
|