Browse Source

Update 'README.md'

天问 1 month ago
parent
commit
9d63c3823e
1 changed files with 31 additions and 1 deletions
  1. 31 1
      README.md

+ 31 - 1
README.md

@@ -1,3 +1,33 @@
 # fastapi_sso
 
-Facebook,Google,Microsoft,github 等单点登录sso插件,类似于国内社会化登录插件
+Facebook,Google,Microsoft,github 等单点登录sso插件,类似于国内社会化登录插件,**注意安装最新版本!**
+
+
+```
+pip install fastapi-sso
+
+from fastapi import FastAPI
+from fastapi_sso import SSO
+from fastapi_sso.sso.github import GithubSSO
+
+app = FastAPI()
+
+sso = SSO()
+
+@app.get("/login")
+def login():
+    # 使用 SSO 实例
+    with sso:
+        # 执行登录逻辑
+        # ...
+
+@app.get("/protected")
+def protected():
+    # 验证登录状态
+    if sso.is_authenticated():
+        return {"message": "Welcome to the protected area!"}
+    else:
+        return {"message": "Please log in first."}
+
+
+```