From ce923306b07a0f6d4e74672bac681e44e4e279b9 Mon Sep 17 00:00:00 2001 From: JinU Choi <11470513+dalbodeule@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:28:12 +0900 Subject: [PATCH] [hotfix] add naver email, nickname fields(optinal). (#153) * [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. --- fastapi_sso/sso/naver.py | 5 +++-- tests/test_openid_responses.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fastapi_sso/sso/naver.py b/fastapi_sso/sso/naver.py index 5cc46c9..c4a4c87 100644 --- a/fastapi_sso/sso/naver.py +++ b/fastapi_sso/sso/naver.py @@ -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, ) diff --git a/tests/test_openid_responses.py b/tests/test_openid_responses.py index 2c151ea..dd58b0b 100644 --- a/tests/test_openid_responses.py +++ b/tests/test_openid_responses.py @@ -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,