Spaces:
Running
Running
from requests_oauthlib import OAuth2Session | |
REDIRECT_URI = "https://app.ingaze.ai/version-test/linkedin_monitoring?debug_mode=true" | |
def create_session(client_id, token=None): | |
"""Creates a requests_oauthlib session.""" | |
# Note: Scope is usually not needed here, only for authorization_url | |
session = OAuth2Session(client_id, token=token, redirect_uri=REDIRECT_URI) | |
# Add required LinkedIn headers | |
session.headers.update({ | |
'LinkedIn-Version': "202502", | |
# REST API often requires this, though sometimes works without. | |
# Let's keep it commented out unless needed, as REST calls seem to work. | |
# 'X-Restli-Protocol-Version': '2.0.0' | |
}) | |
return session |