Skip to content

Commit

Permalink
[hotfix] add naver email, nickname fields(optinal). (#153)
Browse files Browse the repository at this point in the history
* [hotfix] add naver email, nickname fields(optinal).
if require email and nickname, must check its.

* Use Dict.get method in user's information of responses.
  • Loading branch information
dalbodeule authored Apr 18, 2024
1 parent 4a3ef9c commit ce92330
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions fastapi_sso/sso/naver.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ async def get_discovery_document(self) -> DiscoveryDocument:
async def openid_from_response(self, response: dict, session: Optional["httpx.AsyncClient"] = None) -> OpenID:
return OpenID(
id=response["response"]["id"],
display_name=response["response"]["nickname"],
picture=response["response"]["profile_image"] or None,
email=response["response"].get("email"),
display_name=response["response"].get("nickname"),
picture=response["response"].get("profile_image"),
provider=self.provider,
)
4 changes: 2 additions & 2 deletions tests/test_openid_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
),
(
NaverSSO,
{"response": {"nickname": "test", "profile_image": "https://myimage", "id": "test"}},
OpenID(id="test", display_name="test", provider="naver", picture="https://myimage"),
{"response": {"nickname": "test", "profile_image": "https://myimage", "id": "test", "email": "test@example.com"}},
OpenID(id="test", email="test@example.com", display_name="test", provider="naver", picture="https://myimage"),
),
(
MicrosoftSSO,
Expand Down

0 comments on commit ce92330

Please sign in to comment.