Linkedin API v2: Receive vanityname on signup linkedin

柔情痞子 提交于 2021-02-19 08:39:48

问题


I'm doing the sign up integration with LinkedIn for a personal application and i have a big trouble.

We need the vanityName in order to make people visible via linkedin.

How we can redirect them to profiles without using vanityName? I tried with ID unsuccessfully.

I use this endpoint with r_liteprofile scope:

https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,vanityName,profilePicture(displayImage~:playableStreams))

and it returns me:

    {
        "firstName": {
            "localized": {
                "es_ES": "XXX"
            },
            "preferredLocale": {
                "country": "ES",
                "language": "es"
            }
        },
        "lastName": {
            "localized": {
                "es_ES": "XXX"
            },
            "preferredLocale": {
                "country": "ES",
                "language": "es"
            }
        },
        "profilePicture": {
            "displayImage": "XXX",
            "displayImage~": {
                "elements": [...]
            }
        },
        "id": "AX-Wv6r0Ku"
    }

回答1:


You can use the me endpoint of the Profile API in order to Retrieve Current Member's Profile. As example:

   https://api.linkedin.com/v2/me?oauth2_access_token=<user_access_token>

With the result:

{
   "firstName":{
      "localized":{
         "en_US":"Bob"
      },
      "preferredLocale":{
         "country":"US",
         "language":"en"
      }
   },
   "localizedFirstName": "Bob",
   "headline":{
      "localized":{
         "en_US":"API Enthusiast at LinkedIn"
      },
      "preferredLocale":{
         "country":"US",
         "language":"en"
      }
   },
   "localizedHeadline": "API Enthusiast at LinkedIn",
   "vanityName": "bsmith",
   "id":"yrZCpj2Z12",
   "lastName":{
      "localized":{
         "en_US":"Smith"
      },
      "preferredLocale":{
         "country":"US",
         "language":"en"
      }
   },
   "localizedLastName": "Smith",
   "profilePicture": {
        "displayImage": "urn:li:digitalmediaAsset:C4D00AAAAbBCDEFGhiJ"
   }
}

If you want to retrieve only the vanityName field you can use the Field Projections as follow:

https://api.linkedin.com/v2/me?projection=(vanityName)&oauth2_access_token

With the result:

{
    "vanityName": "bsmith"
}

Hope this help



来源:https://stackoverflow.com/questions/57249920/linkedin-api-v2-receive-vanityname-on-signup-linkedin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!