forked from tomasvotava/fastapi-sso
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkakao_example.py
More file actions
37 lines (24 loc) · 761 Bytes
/
Copy pathkakao_example.py
File metadata and controls
37 lines (24 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import uvicorn
from dotenv import load_dotenv
from fastapi import FastAPI, Request
from fastapi_sso.sso.kakao import KakaoSSO
load_dotenv(verbose=True)
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
app = FastAPI()
google_sso = KakaoSSO(
client_id=os.getenv("REST_API_KEY"),
client_secret=os.getenv("REST_API_KEY"),
redirect_uri=os.getenv("REDIRECT_URI"),
use_state=False,
allow_insecure_http=True,
)
@app.get("/kakao/login")
async def kakao():
return await google_sso.get_login_redirect()
@app.get("/kakao/callback")
async def microsoft_callback(request: Request):
user = await google_sso.verify_and_process(request)
return user
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)