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 3
3
from dotenv import load_dotenv
4
4
from social_core .backends .github import GithubOAuth2
5
5
6
+ from fastapi_oauth2 .claims import Claims
6
7
from fastapi_oauth2 .client import OAuth2Client
7
8
from fastapi_oauth2 .config import OAuth2Config
8
9
20
21
client_secret = os .getenv ("OAUTH2_CLIENT_SECRET" ),
21
22
# redirect_uri="http://127.0.0.1:8000/",
22
23
scope = ["user:email" ],
24
+ claims = Claims (
25
+ picture = "avatar_url" ,
26
+ identity = lambda user : "%s:%s" % (user .get ("provider" ), user .get ("id" )),
27
+ ),
23
28
),
24
29
]
25
30
)
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ async def on_auth(user: User):
22
22
# the database and create if not exists
23
23
db : Session = next (get_db ())
24
24
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 ():
26
26
UserModel (** {
27
27
"identity" : user .get ("identity" ),
28
28
"username" : user .get ("username" ),
You can’t perform that action at this time.
0 commit comments