@@ -105,7 +105,7 @@ class UserInfoProvider(ws: WSClient, oauthConfig: OAuthConfig)(implicit ec: Exec
105105 }
106106
107107 def lookupLinkedInCurrentUser (accessToken : String ): Future [OAuthUser ] = {
108- ws.url(" https://api.linkedin.com/v2/me?projection=(id,localizedFirstName,localizedLastName,profilePicture(displayImage~:playableStreams)) " )
108+ ws.url(" https://api.linkedin.com/v2/userinfo " )
109109 .addHttpHeaders(" Authorization" -> s " Bearer $accessToken" ).get().map { response =>
110110 if (response.status == 200 ) {
111111 try {
@@ -166,20 +166,12 @@ object UserInfoProvider {
166166 }
167167
168168 val linkedinOauthUserReads : Reads [OAuthUser ] = (
169- (__ \ " id" ).read[String ] and
170- (__ \ " localizedFirstName" ).read[String ] and
171- (__ \ " localizedLastName" ).read[String ] and
172- // omg.... linkedin.... what have you done.... hardest to use API ever.
173- (__ \ " profilePicture" \ " displayImage~" \ " elements" ).readOptIfMissing[List [JsObject ]]
174- ) { (id, firstName, lastName, images) =>
175-
176- val avatar = images.getOrElse(Nil )
177- .collect(Function .unlift(_.asOpt[LinkedInImageElement ]))
178- .filter(_.size >= 50 )
179- .sortBy(_.size)
180- .map(_.url)
181- .headOption
182-
169+ (__ \ " sub" ).read[String ] and // OIDC uses 'sub' as the unique ID
170+ (__ \ " given_name" ).read[String ] and // Simple first name
171+ (__ \ " family_name" ).read[String ] and // Simple last name
172+ (__ \ " picture" ).readNullable[String ] // Direct URL to the profile picture
173+ ) { (id, firstName, lastName, avatar) =>
174+ // Note: 'sub' is the unique identifier in OIDC
183175 OAuthUser (LinkedIn (id), s " $firstName $lastName" , avatar)
184176 }
185177
0 commit comments