Skip to content

Commit d147615

Browse files
authored
Merge pull request #17 from T1murKO/T1murKO-bug-fix
Fix using headers across multiple instances
2 parents 82a2911 + 5417967 commit d147615

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • twitter_openapi_python/twitter_openapi_python

twitter_openapi_python/twitter_openapi_python/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def get_client_from_cookies(
116116
self,
117117
cookies: dict[str, str],
118118
) -> TwitterOpenapiPythonClient:
119-
api_key = self.api_key
119+
api_key = self.api_key.copy()
120120

121121
if cookies.get("ct0"):
122122
api_key.update({"AuthType": "OAuth2Session"})
@@ -142,15 +142,15 @@ def get_guest_client(self) -> TwitterOpenapiPythonClient:
142142
"GET",
143143
"https://twitter.com",
144144
redirect=False,
145-
headers=self.browser_headers,
145+
headers=self.browser_headers.copy(),
146146
)
147147
cookie = res_1.headers._container["set-cookie"][1:]
148148
session.update(self.cookie_normalize(cookie))
149149
res_2 = http.request(
150150
"GET",
151151
"https://twitter.com",
152152
redirect=False,
153-
headers=self.browser_headers | {"Cookie": self.cookie_to_str(session)},
153+
headers=self.browser_headers.copy() | {"Cookie": self.cookie_to_str(session)},
154154
)
155155

156156
find = re.findall(r'document.cookie="(.*?)";', res_2.data.decode())
@@ -159,7 +159,7 @@ def get_guest_client(self) -> TwitterOpenapiPythonClient:
159159
session.pop("ct0")
160160

161161
if not session.get("gt"):
162-
activate_header = self.browser_headers | {
162+
activate_header = self.browser_headers.copy() | {
163163
"authorization": "Bearer {}".format(self.access_token),
164164
"x-twitter-active-user": "yes",
165165
"x-twitter-client-language": "en",

0 commit comments

Comments
 (0)