如何使用REST API访问领英SSI?

2024-04-25 00:08:06 发布

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

我让API的其余部分使用完全配置文件访问。但有没有办法进入社会销售指数领域?你知道吗

目前为止的代码附在下面。只需要最后一个SSI的字段名会话.get声明。你知道吗

from requests_oauthlib import OAuth2Session
from requests_oauthlib.compliance_fixes import linkedin_compliance_fix

# In case the `redirect_url` does not implement https     
import os                                                   

# Credentials you get from registering a new application
client_id = ''
client_secret = ''
redirect_url = ''

# OAuth endpoints given in the LinkedIn API documentation (check for updates)
authorize_url = 'https://www.linkedin.com/oauth/v2/authorization'
token_url = 'https://www.linkedin.com/oauth/v2/accessToken'

session = OAuth2Session(client_id, redirect_uri=redirect_url)
session = linkedin_compliance_fix(session)
# Authorized Redirect URL (from LinkedIn config)
uri, state = session.authorization_url(authorize_url)

print('Please go here and authorize,', uri)

# Get the authorization verifier code from the callback url
redirect_response = input('Paste the full redirect URL here:')
# Fetch the access token
token = session.fetch_token(token_url,authorization_response=redirect_response,client_secret=client_secret)
print(token)
# Fetch a protected resource, i.e. user profile
r = session.get('https://api.linkedin.com/v1/people/~:(<what do i put here>)?format=json')
print(r.content)

Tags: thefromhttpsimportclienttokenurlget