python linkedin oauth2 - http_api.py 在哪里?

python linkedin oauth2 - where is http_api.py?

我正在尝试让这个示例在 https://github.com/ozgur/python-linkedin 中运行。我正在使用他的例子。当我运行这个代码。我不明白示例中提到的 RETURN_URLauthorization_code。我不确定为什么,我认为这是因为我没有正确设置 HTTP API example。我找不到 http_api.py,当我访问 http://localhost:8080 时,我得到一个 "this site can't be reached"。

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)

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

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

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