Spaces:
Running
Running
Create sessions.py
Browse files- sessions.py +12 -0
sessions.py
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def create_session(client_id, token=None):
|
2 |
+
"""Creates a requests_oauthlib session."""
|
3 |
+
# Note: Scope is usually not needed here, only for authorization_url
|
4 |
+
session = OAuth2Session(client_id, token=token, redirect_uri=REDIRECT_URI)
|
5 |
+
# Add required LinkedIn headers
|
6 |
+
session.headers.update({
|
7 |
+
'LinkedIn-Version': "202502",
|
8 |
+
# REST API often requires this, though sometimes works without.
|
9 |
+
# Let's keep it commented out unless needed, as REST calls seem to work.
|
10 |
+
# 'X-Restli-Protocol-Version': '2.0.0'
|
11 |
+
})
|
12 |
+
return session
|