Skip to content

Commit adf45cf

Browse files
Merge pull request #462 from supertokens/fix/linkedin-oauth
fix: LinkedIn OAuth
2 parents 845532e + 7ac3e02 commit adf45cf

File tree

4 files changed

+12
-21
lines changed

4 files changed

+12
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [unreleased]
1010

11+
## [0.18.2] - 2023-12-05
12+
13+
- Updates LinkedIn OAuth implementation as per the latest [changes](https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin-v2?context=linkedin%2Fconsumer%2Fcontext#authenticating-members).
14+
1115
## [0.18.1] - 2023-12-01
1216

1317
- Fixes bug in dashboard recipe where we did not expose `USER_EMAIL_VERIFY_TOKEN_API` API.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
setup(
7272
name="supertokens_python",
73-
version="0.18.1",
73+
version="0.18.2",
7474
author="SuperTokens",
7575
license="Apache 2.0",
7676
author_email="[email protected]",

supertokens_python/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from __future__ import annotations
1515

1616
SUPPORTED_CDI_VERSIONS = ["3.0"]
17-
VERSION = "0.18.1"
17+
VERSION = "0.18.2"
1818
TELEMETRY = "/telemetry"
1919
USER_COUNT = "/users/count"
2020
USER_DELETE = "/user/remove"

supertokens_python/recipe/thirdparty/providers/linkedin.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ async def get_config_for_client_type(
4242
config = await super().get_config_for_client_type(client_type, user_context)
4343

4444
if config.scope is None:
45-
config.scope = ["r_emailaddress", "r_liteprofile"]
45+
# https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin-v2?context=linkedin%2Fconsumer%2Fcontext#authenticating-members
46+
config.scope = ["openid", "profile", "email"]
4647

4748
return config
4849

@@ -59,31 +60,17 @@ async def get_user_info(
5960
}
6061

6162
raw_user_info_from_provider = RawUserInfoFromProvider({}, {})
63+
# https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin-v2?context=linkedin%2Fconsumer%2Fcontext#sample-api-response
6264
user_info = await do_get_request(
63-
"https://api.linkedin.com/v2/me", headers=headers
65+
"https://api.linkedin.com/v2/userinfo", headers=headers
6466
)
6567
raw_user_info_from_provider.from_user_info_api = user_info
6668

67-
email_api_url = "https://api.linkedin.com/v2/emailAddress"
68-
email_info: Dict[str, Any] = await do_get_request(
69-
email_api_url,
70-
query_params={"q": "members", "projection": "(elements*(handle~))"},
71-
headers=headers,
72-
)
73-
74-
if email_info.get("elements") is not None and len(email_info.get("elements")) > 0: # type: ignore
75-
raw_user_info_from_provider.from_user_info_api["email"] = email_info.get("elements")[0].get("handle~").get("emailAddress") # type: ignore
76-
77-
raw_user_info_from_provider.from_user_info_api = {
78-
**raw_user_info_from_provider.from_user_info_api,
79-
**email_info,
80-
}
81-
8269
return UserInfo(
83-
third_party_user_id=raw_user_info_from_provider.from_user_info_api.get("id"), # type: ignore
70+
third_party_user_id=raw_user_info_from_provider.from_user_info_api.get("sub"), # type: ignore
8471
email=UserInfoEmail(
8572
email=raw_user_info_from_provider.from_user_info_api.get("email"), # type: ignore
86-
is_verified=False,
73+
is_verified=raw_user_info_from_provider.from_user_info_api.get("email_verified"), # type: ignore
8774
),
8875
)
8976

0 commit comments

Comments
 (0)