Skip to content

Commit ead1086

Browse files
committed
GH-9: Add provider in the user entity
1 parent 49115c9 commit ead1086

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/fastapi_oauth2/core.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ async def token_redirect(self, request: Request) -> RedirectResponse:
109109
async with httpx.AsyncClient() as session:
110110
response = await session.post(token_url, headers=headers, content=content, auth=auth)
111111
token = self.oauth_client.parse_request_body_response(json.dumps(response.json()))
112-
data = self.standardize(self.backend.user_data(token.get("access_token")))
112+
token_data = self.standardize(self.backend.user_data(token.get("access_token")))
113+
access_token = request.auth.jwt_create(token_data)
113114

114-
access_token = request.auth.jwt_create({**data, "scope": self.scope})
115115
response = RedirectResponse(self.redirect_uri or request.base_url)
116116
response.set_cookie(
117117
"Authorization",
@@ -123,9 +123,6 @@ async def token_redirect(self, request: Request) -> RedirectResponse:
123123
return response
124124

125125
def standardize(self, data: Dict[str, Any]) -> Dict[str, Any]:
126-
# TODO: Create an issue for collecting all possible field names
127-
# and finish up this method and create a unit-test for each.
128-
# :https://github.com/python-social-auth/social-core/tree/master/social_core/backends
129-
data["identity"] = "%s:%s" % (self.provider, data.get("id"))
130-
data["display_name"] = data.get("name")
126+
data["provider"] = self.provider
127+
data["scope"] = self.scope
131128
return data

0 commit comments

Comments
 (0)