python linkedin oauth2 - http_api.py在哪里?

时间:2017-05-01 13:12:40

标签: python linkedin linkedin-api

我试图让这个例子从https://github.com/ozgur/python-linkedin开始工作。我正在使用他的例子。当我运行此代码时。我没有在示例中谈到RETURN_URLauthorization_code。我不确定原因,我认为是因为我没有正确设置HTTP API example。我无法找到http_api.py,当我访问http://localhost:8080时,我得到了一个"此网站无法访问"。

from linkedin import linkedin

API_KEY = 'wFNJekVpDCJtRPFX812pQsJee-gt0zO4X5XmG6wcfSOSlLocxodAXNMbl0_hw3Vl'
API_SECRET = 'daJDa6_8UcnGMw1yuq9TjoO_PMKukXMo8vEMo7Qv5J-G3SPgrAV0FqFCd0TNjQyG'
RETURN_URL = 'http://localhost:8000'

authentication = linkedin.LinkedInAuthentication(API_KEY, API_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values())
# Optionally one can send custom "state" value that will be returned from OAuth server
# It can be used to track your user state or something else (it's up to you)
# Be aware that this value is sent to OAuth server AS IS - make sure to encode or hash it
#authorization.state = 'your_encoded_message'
print authentication.authorization_url  # open this url on your browser
application = linkedin.LinkedInApplication(authentication)

1 个答案:

答案 0 :(得分:1)

http_api.pyone of the examples provided in the package。这是一个HTTP服务器,它将处理来自LinkedIn的OAuth端点的响应,因此您需要启动它才能使示例正常工作。

如指南中所述,您需要execute that example file才能让服务器正常运行。请注意,您还需要提供以下环境变量:LINKEDIN_API_KEYLINKEDIN_API_SECRET

您可以通过下载repo并调用LINKEDIN_API_KEY=yourkey LINKEDIN_API_SECRET=yoursecret python examples/http_api.py来运行示例文件。请注意,您需要使用Python 3.4才能工作。