关于迁移到 Linkedin 2.0 版的问题 API
Problem about migration to Version 2.0 of Linkedin API
最近linkedin发了一封提醒邮件:
Important update: All developers need to migrate to Version 2.0 of our APIs and OAuth 2.0 by March 1, 2019. Learn more
我正在使用 Linkedin Rest API 来获取授权后的用户信息。
旧的 v1 api 是:
https://api.linkedin.com/v1/people/~
必须更改此请求。我试图提出以下要求:
https://api.linkedin.com/v2/me
获取用户基本信息(如first_name和last_name)
然后:
https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(句柄~))
获取用户邮箱地址
不幸的是第一个请求总是return:
{
"serviceErrorCode": 100,
"message": "Not enough permissions to access: GET /me",
"status": 403
}
我在 Whosebug 上搜索了很多,很多建议您需要作为合作伙伴订阅才能访问 v2 api
迁移指南中的 Linkedin 说:
Does my developer application have access to the v2 API? Any developer application created through the LinkedIn Developer Portal
after December 15, 2018 automatically has access to the v2 API.
What about existing developer applications? If your developer application has made a successful v1 API request since October 1,
2018, your developer application automatically has access to the v2
API.
此外,如果我要求提供电子邮件地址 v2 API,我会得到正确的答复...所以我认为我不需要编译表格就可以成为合作伙伴。
应该是什么问题?
这里是身份验证和 API 调用的完整路径:
1) 进入授权页面申请权限
window.location.href = "https://www.linkedin.com/oauth/v2/authorization?response_type=code" +
"&client_id=" + linkedin_id + "&redirect_uri=" + redirect_uri +
"&state=" + state + "&scope=r_basicprofile+r_emailaddress"
2) 检索访问令牌
request = ("https://www.linkedin.com/oauth/v2/accessToken?grant_type=authorization_code&code=" +
code + "&redirect_uri=" +
redirect_uri + "&client_id="
+ linkedin_id +
"&client_secret=" + linkedin_secret)
response = requests.get(request)
3) 获取访问令牌,我们可以请求用户信息 ALWAYS 403
headers = {"Authorization": "Bearer "+token }
get_user = requests.get('https://api.linkedin.com/v2/me', headers=headers)
4) 得到 user_email 工作
get_user_email = requests.get('https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))', headers=headers)
谢谢
如果您只需要名字和姓氏,请尝试使用 r_liteprofile
而不是 r_basicprofile
试试这个:
第一步更改:
&scope=r_basicprofile+r_emailaddress 进入
&scope=r_liteprofile+r_emailaddress
正在努力获取 r_liteprofile 信息
你会得到 firstName, lastName, profilePicture, id
您应该在请求 AccessToken 时传递 '&scope=r_basicprofile+r_emailaddress'
第一步:
AccessToken 请求将类似于
https://www.linkedin.com/oauth/v2/accessToken?grant_type=authorization_code&code={Your code}&redirect_uri={Yourredirect_uri}&client_id={Your client_id}&client_secret={Your client_secret }&scope=r_liteprofile+r_emailaddress
这将为您 return 您必须使用的 AccessToken,您必须再提出 2 个请求
1 用于电子邮件和个人资料详细信息
第 2 步:
电子邮件请求将类似于
https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))&oauth2_access_token={AccessToken You get from step 1}'
第 3 步:
基本配置文件请求将像
https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,emailAddress,profilePicture(displayImage~:playableStreams))&oauth2_access_token={AccessToken You get from step 1}'
最近linkedin发了一封提醒邮件:
Important update: All developers need to migrate to Version 2.0 of our APIs and OAuth 2.0 by March 1, 2019. Learn more
我正在使用 Linkedin Rest API 来获取授权后的用户信息。 旧的 v1 api 是: https://api.linkedin.com/v1/people/~
必须更改此请求。我试图提出以下要求:
https://api.linkedin.com/v2/me
获取用户基本信息(如first_name和last_name)
然后:
https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(句柄~))
获取用户邮箱地址
不幸的是第一个请求总是return:
{
"serviceErrorCode": 100,
"message": "Not enough permissions to access: GET /me",
"status": 403
}
我在 Whosebug 上搜索了很多,很多建议您需要作为合作伙伴订阅才能访问 v2 api
迁移指南中的 Linkedin 说:
Does my developer application have access to the v2 API? Any developer application created through the LinkedIn Developer Portal after December 15, 2018 automatically has access to the v2 API.
What about existing developer applications? If your developer application has made a successful v1 API request since October 1, 2018, your developer application automatically has access to the v2 API.
此外,如果我要求提供电子邮件地址 v2 API,我会得到正确的答复...所以我认为我不需要编译表格就可以成为合作伙伴。
应该是什么问题?
这里是身份验证和 API 调用的完整路径:
1) 进入授权页面申请权限
window.location.href = "https://www.linkedin.com/oauth/v2/authorization?response_type=code" +
"&client_id=" + linkedin_id + "&redirect_uri=" + redirect_uri +
"&state=" + state + "&scope=r_basicprofile+r_emailaddress"
2) 检索访问令牌
request = ("https://www.linkedin.com/oauth/v2/accessToken?grant_type=authorization_code&code=" +
code + "&redirect_uri=" +
redirect_uri + "&client_id="
+ linkedin_id +
"&client_secret=" + linkedin_secret)
response = requests.get(request)
3) 获取访问令牌,我们可以请求用户信息 ALWAYS 403
headers = {"Authorization": "Bearer "+token }
get_user = requests.get('https://api.linkedin.com/v2/me', headers=headers)
4) 得到 user_email 工作
get_user_email = requests.get('https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))', headers=headers)
谢谢
如果您只需要名字和姓氏,请尝试使用 r_liteprofile
而不是 r_basicprofile
试试这个:
第一步更改: &scope=r_basicprofile+r_emailaddress 进入 &scope=r_liteprofile+r_emailaddress
正在努力获取 r_liteprofile 信息 你会得到 firstName, lastName, profilePicture, id
您应该在请求 AccessToken 时传递 '&scope=r_basicprofile+r_emailaddress'
第一步: AccessToken 请求将类似于
https://www.linkedin.com/oauth/v2/accessToken?grant_type=authorization_code&code={Your code}&redirect_uri={Yourredirect_uri}&client_id={Your client_id}&client_secret={Your client_secret }&scope=r_liteprofile+r_emailaddress
这将为您 return 您必须使用的 AccessToken,您必须再提出 2 个请求 1 用于电子邮件和个人资料详细信息
第 2 步: 电子邮件请求将类似于
https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))&oauth2_access_token={AccessToken You get from step 1}'
第 3 步: 基本配置文件请求将像
https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,emailAddress,profilePicture(displayImage~:playableStreams))&oauth2_access_token={AccessToken You get from step 1}'