File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -42,12 +42,14 @@ middleware configuration is declared with the `OAuth2Config` and `OAuth2Client`
42
42
- ` client_secret ` - The OAuth2 client secret for the particular provider.
43
43
- ` redirect_uri ` - The OAuth2 redirect URI to redirect to after success. Defaults to the base URL.
44
44
- ` scope ` - The OAuth2 scope for the particular provider. Defaults to ` [] ` .
45
+ - ` claims ` - Claims mapping for the certain provider.
45
46
46
47
It is also important to mention that for the configured clients of the auth providers, the authorization URLs are
47
48
accessible by the ` /oauth2/{provider}/auth ` path where the ` provider ` variable represents the exact value of the auth
48
49
provider backend ` name ` attribute.
49
50
50
51
``` python
52
+ from fastapi_oauth2.claims import Claims
51
53
from fastapi_oauth2.client import OAuth2Client
52
54
from fastapi_oauth2.config import OAuth2Config
53
55
from social_core.backends.github import GithubOAuth2
@@ -64,6 +66,10 @@ oauth2_config = OAuth2Config(
64
66
client_secret = os.getenv(" OAUTH2_CLIENT_SECRET" ),
65
67
redirect_uri = " https://pysnippet.org/" ,
66
68
scope = [" user:email" ],
69
+ claims = Claims(
70
+ picture = " avatar_url" ,
71
+ identity = lambda user : " %s :%s " % (user.get(" provider" ), user.get(" id" )),
72
+ ),
67
73
),
68
74
]
69
75
)
You can’t perform that action at this time.
0 commit comments