flask-githubkit 0.1.2__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flask_githubkit-0.1.2/src/flask_githubkit.egg-info → flask_githubkit-0.1.3}/PKG-INFO +20 -11
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/README.md +18 -10
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/pyproject.toml +2 -1
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/src/flask_githubkit/auth.py +9 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3/src/flask_githubkit.egg-info}/PKG-INFO +20 -11
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/LICENSE +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/setup.cfg +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/src/flask_githubkit/__init__.py +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/src/flask_githubkit/config.py +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/src/flask_githubkit/py.typed +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/src/flask_githubkit/store.py +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/src/flask_githubkit.egg-info/SOURCES.txt +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/src/flask_githubkit.egg-info/dependency_links.txt +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/src/flask_githubkit.egg-info/requires.txt +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/src/flask_githubkit.egg-info/top_level.txt +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/tests/test_auth.py +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/tests/test_config.py +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/tests/test_examples.py +0 -0
- {flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/tests/test_store.py +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flask-githubkit
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Flask extension for GitHub OAuth login, built on GitHubKit. Handles expiring-token refresh and server-side sessions.
|
|
5
5
|
Author: LJFCoding
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/LJFCoding/flask-githubkit
|
|
8
8
|
Project-URL: Repository, https://github.com/LJFCoding/flask-githubkit
|
|
9
9
|
Project-URL: Issues, https://github.com/LJFCoding/flask-githubkit/issues
|
|
10
|
+
Project-URL: Documentation, https://flask-githubkit.readthedocs.io/en/latest/
|
|
10
11
|
Keywords: flask,github,githubkit,oauth,authentication
|
|
11
12
|
Classifier: Framework :: Flask
|
|
12
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -35,16 +36,24 @@ A Flask extension for GitHub OAuth login, built on
|
|
|
35
36
|
[GitHubKit](https://github.com/yanyongyu/githubkit). It handles expiring-token
|
|
36
37
|
refresh and stores tokens in `flask.session`.
|
|
37
38
|
|
|
39
|
+
Documentation: [flask-githubkit.readthedocs.io](https://flask-githubkit.readthedocs.io/en/latest/)
|
|
40
|
+
|
|
38
41
|
## Installation
|
|
39
42
|
|
|
40
|
-
Install the release
|
|
43
|
+
Install the latest release from PyPI:
|
|
44
|
+
|
|
45
|
+
```console
|
|
46
|
+
pip install flask-githubkit
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
To pin a release or install directly from GitHub:
|
|
41
50
|
|
|
42
51
|
```console
|
|
43
|
-
pip install "flask-githubkit
|
|
52
|
+
pip install "flask-githubkit==0.1.3"
|
|
53
|
+
pip install "flask-githubkit @ git+https://github.com/LJFCoding/flask-githubkit.git@v0.1.3"
|
|
44
54
|
```
|
|
45
55
|
|
|
46
|
-
It
|
|
47
|
-
find it. It requires Python 3.10+ and installs Flask, GitHubKit and httpx.
|
|
56
|
+
It requires Python 3.10+ and installs Flask, GitHubKit and httpx.
|
|
48
57
|
|
|
49
58
|
For local development, install the test dependencies with
|
|
50
59
|
`pip install -e ".[test]"`.
|
|
@@ -141,15 +150,15 @@ def create_app():
|
|
|
141
150
|
|
|
142
151
|
## Examples
|
|
143
152
|
|
|
144
|
-
Each file in [examples/](examples) is a complete app. They are checked by the
|
|
153
|
+
Each file in [examples/](https://github.com/LJFCoding/flask-githubkit/tree/main/examples) is a complete app. They are checked by the
|
|
145
154
|
test suite, which confirms the login route redirects to GitHub.
|
|
146
155
|
|
|
147
156
|
| File | Shows |
|
|
148
157
|
| --- | --- |
|
|
149
|
-
| [single_file.py](examples/single_file.py) | A module-level app with `GitHub(app)` |
|
|
150
|
-
| [factory.py](examples/factory.py) | An app factory with `init_app` and the optional config keys |
|
|
151
|
-
| [blueprint.py](examples/blueprint.py) | Login routes in a blueprint; the `auth.login` endpoint is found from `@github.login` |
|
|
152
|
-
| [routes.py](examples/routes.py) | A `login_required` decorator and a route that calls the GitHub API |
|
|
158
|
+
| [single_file.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/single_file.py) | A module-level app with `GitHub(app)` |
|
|
159
|
+
| [factory.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/factory.py) | An app factory with `init_app` and the optional config keys |
|
|
160
|
+
| [blueprint.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/blueprint.py) | Login routes in a blueprint; the `auth.login` endpoint is found from `@github.login` |
|
|
161
|
+
| [routes.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/routes.py) | A `login_required` decorator and a route that calls the GitHub API |
|
|
153
162
|
|
|
154
163
|
Set `GITHUB_CLIENT_ID`, `GITHUB_CLIENT_SECRET` and `SECRET_KEY` in your
|
|
155
164
|
environment, then run one with, for example,
|
|
@@ -202,7 +211,7 @@ github = flask_githubkit.GitHub(
|
|
|
202
211
|
OAuth flow. You can also call `github.login()` inside a view and return
|
|
203
212
|
the result, which is useful if you want to run code first. The decorated
|
|
204
213
|
function's body never runs.
|
|
205
|
-
- `@callback` wraps the callback view.
|
|
214
|
+
- `@github.callback` wraps the callback view.
|
|
206
215
|
- `client()` returns the request-cached GitHubKit `GitHub` client, or `None`
|
|
207
216
|
when there is no valid stored token.
|
|
208
217
|
- `logout()` removes the stored GitHub token from the session.
|
|
@@ -4,16 +4,24 @@ A Flask extension for GitHub OAuth login, built on
|
|
|
4
4
|
[GitHubKit](https://github.com/yanyongyu/githubkit). It handles expiring-token
|
|
5
5
|
refresh and stores tokens in `flask.session`.
|
|
6
6
|
|
|
7
|
+
Documentation: [flask-githubkit.readthedocs.io](https://flask-githubkit.readthedocs.io/en/latest/)
|
|
8
|
+
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
9
|
-
Install the release
|
|
11
|
+
Install the latest release from PyPI:
|
|
12
|
+
|
|
13
|
+
```console
|
|
14
|
+
pip install flask-githubkit
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
To pin a release or install directly from GitHub:
|
|
10
18
|
|
|
11
19
|
```console
|
|
12
|
-
pip install "flask-githubkit
|
|
20
|
+
pip install "flask-githubkit==0.1.3"
|
|
21
|
+
pip install "flask-githubkit @ git+https://github.com/LJFCoding/flask-githubkit.git@v0.1.3"
|
|
13
22
|
```
|
|
14
23
|
|
|
15
|
-
It
|
|
16
|
-
find it. It requires Python 3.10+ and installs Flask, GitHubKit and httpx.
|
|
24
|
+
It requires Python 3.10+ and installs Flask, GitHubKit and httpx.
|
|
17
25
|
|
|
18
26
|
For local development, install the test dependencies with
|
|
19
27
|
`pip install -e ".[test]"`.
|
|
@@ -110,15 +118,15 @@ def create_app():
|
|
|
110
118
|
|
|
111
119
|
## Examples
|
|
112
120
|
|
|
113
|
-
Each file in [examples/](examples) is a complete app. They are checked by the
|
|
121
|
+
Each file in [examples/](https://github.com/LJFCoding/flask-githubkit/tree/main/examples) is a complete app. They are checked by the
|
|
114
122
|
test suite, which confirms the login route redirects to GitHub.
|
|
115
123
|
|
|
116
124
|
| File | Shows |
|
|
117
125
|
| --- | --- |
|
|
118
|
-
| [single_file.py](examples/single_file.py) | A module-level app with `GitHub(app)` |
|
|
119
|
-
| [factory.py](examples/factory.py) | An app factory with `init_app` and the optional config keys |
|
|
120
|
-
| [blueprint.py](examples/blueprint.py) | Login routes in a blueprint; the `auth.login` endpoint is found from `@github.login` |
|
|
121
|
-
| [routes.py](examples/routes.py) | A `login_required` decorator and a route that calls the GitHub API |
|
|
126
|
+
| [single_file.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/single_file.py) | A module-level app with `GitHub(app)` |
|
|
127
|
+
| [factory.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/factory.py) | An app factory with `init_app` and the optional config keys |
|
|
128
|
+
| [blueprint.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/blueprint.py) | Login routes in a blueprint; the `auth.login` endpoint is found from `@github.login` |
|
|
129
|
+
| [routes.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/routes.py) | A `login_required` decorator and a route that calls the GitHub API |
|
|
122
130
|
|
|
123
131
|
Set `GITHUB_CLIENT_ID`, `GITHUB_CLIENT_SECRET` and `SECRET_KEY` in your
|
|
124
132
|
environment, then run one with, for example,
|
|
@@ -171,7 +179,7 @@ github = flask_githubkit.GitHub(
|
|
|
171
179
|
OAuth flow. You can also call `github.login()` inside a view and return
|
|
172
180
|
the result, which is useful if you want to run code first. The decorated
|
|
173
181
|
function's body never runs.
|
|
174
|
-
- `@callback` wraps the callback view.
|
|
182
|
+
- `@github.callback` wraps the callback view.
|
|
175
183
|
- `client()` returns the request-cached GitHubKit `GitHub` client, or `None`
|
|
176
184
|
when there is no valid stored token.
|
|
177
185
|
- `logout()` removes the stored GitHub token from the session.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "flask-githubkit"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.3"
|
|
8
8
|
description = "Flask extension for GitHub OAuth login, built on GitHubKit. Handles expiring-token refresh and server-side sessions."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -35,6 +35,7 @@ lint = ["ruff", "mypy"]
|
|
|
35
35
|
Homepage = "https://github.com/LJFCoding/flask-githubkit"
|
|
36
36
|
Repository = "https://github.com/LJFCoding/flask-githubkit"
|
|
37
37
|
Issues = "https://github.com/LJFCoding/flask-githubkit/issues"
|
|
38
|
+
Documentation = "https://flask-githubkit.readthedocs.io/en/latest/"
|
|
38
39
|
|
|
39
40
|
[tool.setuptools.packages.find]
|
|
40
41
|
where = ["src"]
|
|
@@ -57,6 +57,7 @@ class GitHub:
|
|
|
57
57
|
self.init_app(app)
|
|
58
58
|
|
|
59
59
|
def init_app(self, app: flask.Flask) -> None:
|
|
60
|
+
"""Register the ``AuthExpiredError`` handler on ``app``."""
|
|
60
61
|
app.register_error_handler(
|
|
61
62
|
githubkit.exception.AuthExpiredError, self._expired
|
|
62
63
|
)
|
|
@@ -98,6 +99,13 @@ class GitHub:
|
|
|
98
99
|
def callback(
|
|
99
100
|
self, view_func: collections.abc.Callable[..., ViewResult]
|
|
100
101
|
) -> collections.abc.Callable[..., ViewResult]:
|
|
102
|
+
"""Wrap the callback view.
|
|
103
|
+
|
|
104
|
+
The wrapper checks the OAuth ``state``, exchanges the code and
|
|
105
|
+
saves the token. It then calls the view with the access token,
|
|
106
|
+
or with ``None`` if the user denied access.
|
|
107
|
+
"""
|
|
108
|
+
|
|
101
109
|
@functools.wraps(view_func)
|
|
102
110
|
def wrapper(*args: typing.Any, **kwargs: typing.Any) -> ViewResult:
|
|
103
111
|
if not self._check_state():
|
|
@@ -164,6 +172,7 @@ class GitHub:
|
|
|
164
172
|
return github
|
|
165
173
|
|
|
166
174
|
def logout(self) -> None:
|
|
175
|
+
"""Remove the stored token and any cached client."""
|
|
167
176
|
flask_githubkit.store.Token.clear()
|
|
168
177
|
flask.g.pop(CLIENT_ATTR, None)
|
|
169
178
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flask-githubkit
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Flask extension for GitHub OAuth login, built on GitHubKit. Handles expiring-token refresh and server-side sessions.
|
|
5
5
|
Author: LJFCoding
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/LJFCoding/flask-githubkit
|
|
8
8
|
Project-URL: Repository, https://github.com/LJFCoding/flask-githubkit
|
|
9
9
|
Project-URL: Issues, https://github.com/LJFCoding/flask-githubkit/issues
|
|
10
|
+
Project-URL: Documentation, https://flask-githubkit.readthedocs.io/en/latest/
|
|
10
11
|
Keywords: flask,github,githubkit,oauth,authentication
|
|
11
12
|
Classifier: Framework :: Flask
|
|
12
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -35,16 +36,24 @@ A Flask extension for GitHub OAuth login, built on
|
|
|
35
36
|
[GitHubKit](https://github.com/yanyongyu/githubkit). It handles expiring-token
|
|
36
37
|
refresh and stores tokens in `flask.session`.
|
|
37
38
|
|
|
39
|
+
Documentation: [flask-githubkit.readthedocs.io](https://flask-githubkit.readthedocs.io/en/latest/)
|
|
40
|
+
|
|
38
41
|
## Installation
|
|
39
42
|
|
|
40
|
-
Install the release
|
|
43
|
+
Install the latest release from PyPI:
|
|
44
|
+
|
|
45
|
+
```console
|
|
46
|
+
pip install flask-githubkit
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
To pin a release or install directly from GitHub:
|
|
41
50
|
|
|
42
51
|
```console
|
|
43
|
-
pip install "flask-githubkit
|
|
52
|
+
pip install "flask-githubkit==0.1.3"
|
|
53
|
+
pip install "flask-githubkit @ git+https://github.com/LJFCoding/flask-githubkit.git@v0.1.3"
|
|
44
54
|
```
|
|
45
55
|
|
|
46
|
-
It
|
|
47
|
-
find it. It requires Python 3.10+ and installs Flask, GitHubKit and httpx.
|
|
56
|
+
It requires Python 3.10+ and installs Flask, GitHubKit and httpx.
|
|
48
57
|
|
|
49
58
|
For local development, install the test dependencies with
|
|
50
59
|
`pip install -e ".[test]"`.
|
|
@@ -141,15 +150,15 @@ def create_app():
|
|
|
141
150
|
|
|
142
151
|
## Examples
|
|
143
152
|
|
|
144
|
-
Each file in [examples/](examples) is a complete app. They are checked by the
|
|
153
|
+
Each file in [examples/](https://github.com/LJFCoding/flask-githubkit/tree/main/examples) is a complete app. They are checked by the
|
|
145
154
|
test suite, which confirms the login route redirects to GitHub.
|
|
146
155
|
|
|
147
156
|
| File | Shows |
|
|
148
157
|
| --- | --- |
|
|
149
|
-
| [single_file.py](examples/single_file.py) | A module-level app with `GitHub(app)` |
|
|
150
|
-
| [factory.py](examples/factory.py) | An app factory with `init_app` and the optional config keys |
|
|
151
|
-
| [blueprint.py](examples/blueprint.py) | Login routes in a blueprint; the `auth.login` endpoint is found from `@github.login` |
|
|
152
|
-
| [routes.py](examples/routes.py) | A `login_required` decorator and a route that calls the GitHub API |
|
|
158
|
+
| [single_file.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/single_file.py) | A module-level app with `GitHub(app)` |
|
|
159
|
+
| [factory.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/factory.py) | An app factory with `init_app` and the optional config keys |
|
|
160
|
+
| [blueprint.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/blueprint.py) | Login routes in a blueprint; the `auth.login` endpoint is found from `@github.login` |
|
|
161
|
+
| [routes.py](https://github.com/LJFCoding/flask-githubkit/blob/main/examples/routes.py) | A `login_required` decorator and a route that calls the GitHub API |
|
|
153
162
|
|
|
154
163
|
Set `GITHUB_CLIENT_ID`, `GITHUB_CLIENT_SECRET` and `SECRET_KEY` in your
|
|
155
164
|
environment, then run one with, for example,
|
|
@@ -202,7 +211,7 @@ github = flask_githubkit.GitHub(
|
|
|
202
211
|
OAuth flow. You can also call `github.login()` inside a view and return
|
|
203
212
|
the result, which is useful if you want to run code first. The decorated
|
|
204
213
|
function's body never runs.
|
|
205
|
-
- `@callback` wraps the callback view.
|
|
214
|
+
- `@github.callback` wraps the callback view.
|
|
206
215
|
- `client()` returns the request-cached GitHubKit `GitHub` client, or `None`
|
|
207
216
|
when there is no valid stored token.
|
|
208
217
|
- `logout()` removes the stored GitHub token from the session.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flask_githubkit-0.1.2 → flask_githubkit-0.1.3}/src/flask_githubkit.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|