Linkedin API Python
我正在尝试登录Linkedin。我创建了应用程序并提取了客户端密钥和客户端密钥。我还添加了重定向URL。 我有一个错误: linkedin.exceptions.LinkedInError:410客户端错误:url已消失::此资源在v1 API下不再可用Linkedin API Python,python,linkedin,Python,Linkedin,我正在尝试登录Linkedin。我创建了应用程序并提取了客户端密钥和客户端密钥。我还添加了重定向URL。 我有一个错误: linkedin.exceptions.LinkedInError:410客户端错误:url已消失::此资源在v1 API下不再可用 v1 API不再受支持。 请求版本1.0 API的应用程序在删除服务时可能会遇到问题。因此,强烈建议将其从v1更改为v2 链接: 尝试使用新的API集(当前为v2)更新您的代码,它将按照您的期望完美工作。 链接: 希望有帮助 您的问题是什么?我
v1 API不再受支持。
请求版本1.0 API的应用程序在删除服务时可能会遇到问题。因此,强烈建议将其从
v1
更改为v2
链接:
尝试使用新的API集(当前为v2)更新您的代码,它将按照您的期望完美工作。
链接:
希望有帮助 您的问题是什么?我现在无法获取\u profile()信息,API的响应是410,这意味着此特定资源不再可用。所以基本上地址不在那里,不要怪自己的代码。我这样做了,但现在我有了这个错误:401客户端错误:url未经授权:将
请求\u令牌\u url
更改为https://www.linkedin.com/oauth/v2/accessToken
,然后让我知道您得到了什么响应。有关更多详细信息,请参阅此链接:异常:无效响应400您必须对代码进行一些更改,如下所述:
# pip install python-linkedin
from linkedin import linkedin
import oauth2 as oauth
import urllib
consumer_key = ''
consumer_secret = ''
consumer = oauth.Consumer(consumer_key, consumer_secret)
client = oauth.Client(consumer)
request_token_url = 'https://api.linkedin.com/uas/oauth/requestToken'
resp, content = client.request(request_token_url, "POST")
if resp['status'] != '200':
raise Exception('Invalid response %s.' % resp['status'])
content_utf8 = str(content, 'utf-8')
request_token = dict(urllib.parse.parse_qsl(content_utf8))
authorize_url = request_token['xoauth_request_auth_url']
print('Go to the following link in your browser:', "\n")
print(authorize_url + '?oauth_token=' + request_token['oauth_token'])
accepted = 'n'
while accepted.lower() == 'n':
accepted = input('Have you authorized me? (y/n)')
oauth_verifier = input('What is the PIN?')
access_token_url = 'https://api.linkedin.com/uas/oauth/accessToken'
token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret'])
token.set_verifier(oauth_verifier)
client = oauth.Client(consumer, token)
resp, content = client.request(access_token_url, 'POST')
content8 = str(content, 'utf-8')
access_token = dict(urllib.parse.parse_qsl(content8))
USER_TOKEN = access_token['oauth_token']
USER_SECRET = access_token['oauth_token_secret']
RETURN_URL = 'http://localhost:8080'
authentication = linkedin.LinkedInDeveloperAuthentication(
consumer_key,
consumer_secret,
USER_TOKEN,
USER_SECRET,
RETURN_URL,
linkedin.PERMISSIONS.enums.values()
)
application = linkedin.LinkedInApplication(authentication)
application.get_profile()