File size: 704 Bytes
5b25269
 
03af851
 
11f2781
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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