Linkedin每次认证新代码python

2024-04-26 18:59:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用Python访问linkedin。下面是我使用的简单代码。在

问题是我每次都需要登录openbrowser来发布返回的\u url以获取授权代码,它在我第一次运行时工作,而这个代码在我重新运行python代码时过期。在

以下是我的代码:

from linkedin import linkedin
API_KEY = '<mykey>'
API_SECRET = '<mysecret>'
RETURN_URL = 'https://www.linkedin.com/uas/oauth/authorize'
authentication = linkedin.LinkedInAuthentication(API_KEY, API_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values())
Url= authentication.authorization_url  # open this url on your browser
print Url
authentication.authorization_code ="<authcode>"
application = linkedin.LinkedInApplication(authentication)
authentication.get_access_token()

Tags: key代码fromimportapiurlsecretauthentication