如何获取linkedIn帐户的用户名

如何获取linkedIn帐户的用户名,linkedin,linkedin-api,Linkedin,Linkedin Api,我已经通过Oauth2协议与LinkedIn实现了singin操作,并接收有关配置文件的响应信息,如图所示: { "localizedLastName": "xxxxxxx", "profilePicture": { "displayImage": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, "firstName": { &quo

我已经通过Oauth2协议与LinkedIn实现了singin操作,并接收有关配置文件的响应信息,如图所示:

{
"localizedLastName": "xxxxxxx",
"profilePicture": {
    "displayImage": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
"firstName": {
    "localized": {
        "fr_FR": "xxxxxxxxxxxx"
    },
   "id": "xxxxxxxx",
    ....
 }
但在我的用例中,我需要存储一个唯一的用户名,我认为我只能从配置文件链接中检索它
那么如何获取此配置文件链接呢?

我想您正在从以下位置查找的
vanityName

vanityName:成员的虚名。虚荣的名字是代表 由于字符串用于公共配置文件URL:
www.linkedin.com/in/{vanityName}

因此,可以将以下旋度与所请求字段上的投影一起使用:

curl -H "Authorization: Bearer <auth-token>" \
"https://api.linkedin.com/v2/me?projection=(localizedFirstName,vanityName)"
应用程序权限

仔细检查您的应用程序是否至少具有
basicprofile
权限(OAuth 2.0范围):默认的
lite配置文件
是不够的。因此,请参见应用程序范围控制台中的
https://www.linkedin.com/developers/apps//auth
您至少应该有:

r_基本档案:使用你的基本档案,包括你的姓名、照片、, 标题和公共配置文件URL


抱歉,它只返回“localizedFirstName”Hi@barsawi13可能是由于缺少范围权限(我已更新了我的答案)我正在使用LinkedIn Api V2和范围r_liteprofile,它没有r_basicprofile范围,因为Api V1自2019年5月以来已被弃用
{
  "vanityName": "bsmith",
  "localizedFirstName": "Bob"
}