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`
4242- ` client_secret ` - The OAuth2 client secret for the particular provider.
4343- ` redirect_uri ` - The OAuth2 redirect URI to redirect to after success. Defaults to the base URL.
4444- ` scope ` - The OAuth2 scope for the particular provider. Defaults to ` [] ` .
45+ - ` claims ` - Claims mapping for the certain provider.
4546
4647It is also important to mention that for the configured clients of the auth providers, the authorization URLs are
4748accessible by the ` /oauth2/{provider}/auth ` path where the ` provider ` variable represents the exact value of the auth
4849provider backend ` name ` attribute.
4950
5051``` python
52+ from fastapi_oauth2.claims import Claims
5153from fastapi_oauth2.client import OAuth2Client
5254from fastapi_oauth2.config import OAuth2Config
5355from social_core.backends.github import GithubOAuth2
@@ -64,6 +66,10 @@ oauth2_config = OAuth2Config(
6466 client_secret = os.getenv(" OAUTH2_CLIENT_SECRET" ),
6567 redirect_uri = " https://pysnippet.org/" ,
6668 scope = [" user:email" ],
69+ claims = Claims(
70+ picture = " avatar_url" ,
71+ identity = lambda user : " %s :%s " % (user.get(" provider" ), user.get(" id" )),
72+ ),
6773 ),
6874 ]
6975)
You can’t perform that action at this time.
0 commit comments