在 linkedin 中获取授权码错误 API

Getting error in authorization code in linkedin API

我已经试过了,但它给出了错误: 从 linkedin 导入 linkedin

API_KEY = '8xxxxxxxxxx'``
API_SECRET = '0Rxxxxxxxxxxxxxx'
RETURN_URL = 'http://localhost:8000'

authentication = linkedin.LinkedInAuthentication(API_KEY, API_SECRET, 
RETURN_URL, linkedin.PERMISSIONS.enums.values())
print (authentication.authorization_url)  
application = linkedin.LinkedInApplication(authentication)

我通过此打印命令获得的 URL 显示错误。 此图错误:https://drive.google.com/open?id=1n81Jg4hXITzIraOLpAENUeYpovaHPSfa

您只需传入您在 linkedin 开发者控制台中选择的那些权限。尝试做:

PERMISSIONS = ['r_basicprofile', 'r_emailaddress'] 
authentication = linkedin.LinkedInAuthentication(API_KEY, API_SECRET, 
RETURN_URL, PERMISSIONS)
...

print authentication.authorization_url ## open this in browser

一旦您授予对应用程序的访问权限,您将被重定向到 RETURN_URL 您提供的 code 查询参数,例如:

http://localhost:8000/?code=SDFKSDiodf8ayfjkdf45....

授权码是上面url中code参数的值,所以要获取访问令牌,你可以

authentication.authorization_code = '<value-of-code-param-in-url>'
accessToken = authentication.get_access_token()