File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 33from dotenv import load_dotenv
44from social_core .backends .github import GithubOAuth2
55
6+ from fastapi_oauth2 .claims import Claims
67from fastapi_oauth2 .client import OAuth2Client
78from fastapi_oauth2 .config import OAuth2Config
89
2021 client_secret = os .getenv ("OAUTH2_CLIENT_SECRET" ),
2122 # redirect_uri="http://127.0.0.1:8000/",
2223 scope = ["user:email" ],
24+ claims = Claims (
25+ picture = "avatar_url" ,
26+ identity = lambda user : "%s:%s" % (user .get ("provider" ), user .get ("id" )),
27+ ),
2328 ),
2429 ]
2530)
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ async def on_auth(user: User):
2222 # the database and create if not exists
2323 db : Session = next (get_db ())
2424 query = db .query (UserModel )
25- if not query .filter_by (identity = user .identity ).first ():
25+ if user . identity and not query .filter_by (identity = user .identity ).first ():
2626 UserModel (** {
2727 "identity" : user .get ("identity" ),
2828 "username" : user .get ("username" ),
You can’t perform that action at this time.
0 commit comments