Skip to content

Commit a9c17c5

Browse files
committed
remove csrf auth method, because it doesnt work
1 parent c86206a commit a9c17c5

File tree

6 files changed

+10
-28
lines changed

6 files changed

+10
-28
lines changed

.github/workflows/pytest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ jobs:
2323
run: pytest -vvvv -s
2424
env:
2525
LEETCODE_SESSION_ID: ${{ secrets.LEETCODE_SESSION }}
26+
LEETCODE_CSRF_TOKEN: ${{ secrets.LEETCODE_CSRF_TOKEN}}

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
![build](https://github.com/prius/python-leetcode/actions/workflows/publish-to-pypi.yml/badge.svg)
2-
![tests](https://github.com/prius/python-leetcode/actions/workflows/pytest.yml/badge.svg)
1+
![build](https://github.com/fspv/python-leetcode/actions/workflows/publish-to-pypi.yml/badge.svg)
2+
![tests](https://github.com/fspv/python-leetcode/actions/workflows/pytest.yml/badge.svg)
33
![pypi](https://badge.fury.io/py/python-leetcode.svg)
44
![pypi-downloads](https://img.shields.io/pypi/dm/python-leetcode)
55
![python-versions](https://img.shields.io/pypi/pyversions/python-leetcode)
@@ -9,7 +9,7 @@
99

1010
This repo contains a python client to access all known so far methods of Leetcode API.
1111

12-
The code is autogenerated by swagger. Swagger reference can be found here: [https://github.com/prius/leetcode-swagger](https://github.com/prius/leetcode-swagger)
12+
The code is autogenerated by swagger. Swagger reference can be found here: [https://github.com/fspv/leetcode-swagger](https://github.com/fspv/leetcode-swagger)
1313

1414
PyPi package link: [https://pypi.org/project/python-leetcode/](https://pypi.org/project/python-leetcode/)
1515

@@ -30,10 +30,6 @@ import leetcode
3030
leetcode_session = "yyy"
3131
csrf_token = "xxx"
3232

33-
# Experimental: Or CSRF token can be obtained automatically
34-
import leetcode.auth
35-
csrf_token = leetcode.auth.get_csrf_cookie(leetcode_session)
36-
3733
configuration = leetcode.Configuration()
3834

3935
configuration.api_key["x-csrftoken"] = csrf_token
@@ -168,8 +164,8 @@ In this case memoization topic is one of the targets for improvement, so I can g
168164

169165
## Example services using this library
170166

171-
* Anki cards generator [https://github.com/prius/leetcode-anki](https://github.com/prius/leetcode-anki)
172-
* Leetcode helper website [https://github.com/prius/grind-helper](https://github.com/prius/grind-helper)
167+
* Anki cards generator [https://github.com/fspv/leetcode-anki](https://github.com/fspv/leetcode-anki)
168+
* Leetcode helper website [https://github.com/fspv/grind-helper](https://github.com/fspv/grind-helper)
173169

174170
## Additional info
175171
You can find other examples of usage in `example.py`

example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
from __future__ import annotations
22

33
import os
4-
import sys
54
from time import sleep
65

76
import leetcode
8-
import leetcode.auth
97

108
# Initialize client
119
configuration = leetcode.Configuration()
@@ -14,7 +12,7 @@
1412
# fields which contain corresponding cookies from web browser
1513
leetcode_session: str = os.environ["LEETCODE_SESSION_ID"]
1614

17-
csrf_token: str = leetcode.auth.get_csrf_cookie(leetcode_session)
15+
csrf_token = os.environ["LEETCODE_CSRF_TOKEN"]
1816

1917
configuration.api_key["x-csrftoken"] = csrf_token
2018
configuration.api_key["csrftoken"] = csrf_token

leetcode/auth.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from setuptools import find_packages, setup # noqa: H301
1515

1616
NAME = "python-leetcode"
17-
VERSION = "1.2.2"
17+
VERSION = "1.2.3"
1818

1919
with open("README.md") as readme:
2020
DESCRIPTION: str = readme.read()

test/base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import leetcode.api.default_api
55
import leetcode.api_client
6-
import leetcode.auth
76
import leetcode.configuration
87

98

@@ -25,9 +24,9 @@ def _api_instance(
2524
) -> None:
2625
self._api_instance_containter = value
2726

28-
def setup(self) -> None:
27+
def setup_method(self) -> None:
2928
session_id = os.environ["LEETCODE_SESSION_ID"]
30-
csrftoken = leetcode.auth.get_csrf_cookie(session_id)
29+
csrftoken = os.environ["LEETCODE_CSRF_TOKEN"]
3130

3231
configuration = leetcode.configuration.Configuration()
3332

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy