Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 51ae70e

Browse files
authored
fix(kakao): Change deprecated properties to profile information
* fix(kakao): Change deprecated properties to profile information * fix(kakao): Remove trailing whitespace in tests.py * fix(kakao): Fallback to the original fields in case the new lookups fail. * style(kakao): Format code with black.
1 parent 92c1918 commit 51ae70e

File tree

2 files changed

+44
-17
lines changed

2 files changed

+44
-17
lines changed

allauth/socialaccount/providers/kakao/provider.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@
77
class KakaoAccount(ProviderAccount):
88
@property
99
def properties(self):
10-
return self.account.extra_data.get("properties")
10+
return self.account.extra_data.get("properties", {})
11+
12+
@property
13+
def profile(self):
14+
return self.account.extra_data.get("kakao_account", {}).get("profile", {})
1115

1216
def get_avatar_url(self):
13-
return self.properties.get("profile_image")
17+
return self.profile.get(
18+
"profile_image_url", self.properties.get("profile_image")
19+
)
1420

1521
def to_str(self):
1622
dflt = super(KakaoAccount, self).to_str()
17-
return self.properties.get("nickname", dflt)
23+
return self.profile.get("nickname", self.properties.get("nickname", dflt))
1824

1925

2026
class KakaoProvider(OAuth2Provider):
@@ -28,7 +34,7 @@ def extract_uid(self, data):
2834

2935
def extract_common_fields(self, data):
3036
email = data.get("kakao_account", {}).get("email")
31-
nickname = data.get("properties", {}).get("nickname")
37+
nickname = data.get("kakao_account", {}).get("profile", {}).get("nickname")
3238

3339
return dict(email=email, username=nickname)
3440

allauth/socialaccount/providers/kakao/tests.py

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,43 @@ class KakaoTests(OAuth2TestsMixin, TestCase):
1010
kakao_data = """
1111
{
1212
"id": 123456789,
13-
"properties": {
14-
"nickname": "\uc9c0\uc724",
15-
"thumbnail_image": "http://xxx.kakao.co.kr/.../aaa.jpg",
16-
"profile_image": "http://xxx.kakao.co.kr/.../bbb.jpg"
17-
},
13+
"connected_at": "2022-04-11T01:45:28Z",
1814
"kakao_account": {
19-
"has_email": true,
15+
"profile_nickname_needs_agreement": false,
16+
"profile_image_needs_agreement": false,
17+
"profile": {
18+
"nickname": "홍길동",
19+
"thumbnail_image_url": "http://yyy.kakao.com/.../img_110x110.jpg",
20+
"profile_image_url": "http://yyy.kakao.com/dn/.../img_640x640.jpg",
21+
"is_default_image":false,
22+
"is_default_nickname": false
23+
},
24+
"name_needs_agreement":false,
25+
"name":"홍길동",
26+
"email_needs_agreement":false,
2027
"is_email_valid": true,
2128
"is_email_verified": true,
22-
"email": "[email protected]",
23-
"has_age_range": true,
24-
"age_range": "20~29",
25-
"has_birthday": true,
26-
"birthday": "1130",
27-
"has_gender": true,
28-
"gender": "female"
29+
"email": "[email protected]",
30+
"age_range_needs_agreement":false,
31+
"age_range":"20~29",
32+
"birthyear_needs_agreement": false,
33+
"birthyear": "2002",
34+
"birthday_needs_agreement":false,
35+
"birthday":"1130",
36+
"birthday_type":"SOLAR",
37+
"gender_needs_agreement":false,
38+
"gender":"female",
39+
"phone_number_needs_agreement": false,
40+
"phone_number": "+82 010-1234-5678",
41+
"ci_needs_agreement": false,
42+
"ci": "CI",
43+
"ci_authenticated_at": "2019-03-11T11:25:22Z"
44+
},
45+
"properties":{
46+
"CUSTOM_PROPERTY_KEY": "CUSTOM_PROPERTY_VALUE"
47+
},
48+
"for_partner": {
49+
"uuid": "UUID"
2950
}
3051
}
3152
"""

0 commit comments

Comments
 (0)