File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55
66class LeetCodeAuth :
7-
87 def __init__ (self ):
98 self .session = Session ()
109
11- self .session .headers .update (
12- {
13- "User-Agent" : Config .USER_AGENT ,
14- "Referer" : "https://leetcode.com/" ,
15- "Origin" : "https://leetcode.com" ,
16- "Content-Type" : "application/json" ,
17- }
18- )
10+ self .session .headers .update ({
11+ "User-Agent" : Config .USER_AGENT ,
12+ "Referer" : "https://leetcode.com/" ,
13+ "Origin" : "https://leetcode.com" ,
14+ "Content-Type" : "application/json" ,
15+ "Accept" : "application/json" ,
16+ })
17+
18+ # Authentication cookies
19+ if Config .LEETCODE_SESSION :
20+ self .session .cookies .set (
21+ "LEETCODE_SESSION" ,
22+ Config .LEETCODE_SESSION ,
23+ domain = ".leetcode.com"
24+ )
1925
20- self . session . cookies . update (
21- {
22- "LEETCODE_SESSION" : Config . LEETCODE_SESSION ,
23- "csrftoken" : Config .CSRF_TOKEN ,
24- }
25- )
26+ if Config . CSRF_TOKEN :
27+ self . session . cookies . set (
28+ "csrftoken" ,
29+ Config .CSRF_TOKEN ,
30+ domain = ".leetcode.com"
31+ )
2632
2733 def get_session (self ) -> Session :
28- """Return the configured session."""
2934 return self .session
You can’t perform that action at this time.
0 commit comments