Skip to content

Commit 97fa4fd

Browse files
committed
readme added and uploaded to pip
1 parent 7b0b958 commit 97fa4fd

File tree

1 file changed

+163
-4
lines changed

1 file changed

+163
-4
lines changed

setup.py

Lines changed: 163 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,172 @@
66
"""
77
from setuptools import setup
88

9-
from pathlib import Path
10-
this_directory = Path(__file__).parent
11-
long_description = (this_directory / "README.md").read_text()
9+
long_description = """
10+
# Flask-OneID
11+
12+
![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/Odya-LLC/flask_oneid/OneID%20test/main)
13+
![GitHub release (latest by date)](https://img.shields.io/github/v/release/Odya-LLC/flask_oneid)
14+
![GitHub top language](https://img.shields.io/github/languages/top/Odya-LLC/flask_oneid)
15+
![GitHub](https://img.shields.io/github/license/Odya-LLC/flask_oneid)
16+
> Only for Uzbekistan
17+
18+
OneID integration for Flask application
19+
20+
## Links
21+
22+
* [About OneID](https://id.egov.uz/)
23+
* [Examples](https://github.com/Odya-LLC/flask_oneid/tree/main/examples)
24+
25+
## How it Works
26+
27+
### Install
28+
29+
```
30+
pip install Flask-OneID
31+
```
32+
33+
### Add your credentials from OneID to config file
34+
35+
```python
36+
ONEID_LOGIN = "your login"
37+
ONEID_PASSWORD = "your pasword"
38+
ONEID_URL = "url from OneID" # defaul https://sso.egov.uz/sso/oauth/Authorization.do
39+
40+
```
41+
42+
### Create Flask App With OneID
43+
44+
```python
45+
from flask_oneid import OneID
46+
from flask import *
47+
def create_app():
48+
oneid = OneID()
49+
app = Flask(__name__)
50+
app.config.from_pyfile('config.py')
51+
oneid.init_app(app)
52+
53+
@app.route("/", methods=['GET'])
54+
def index():
55+
return "Hello World"
56+
57+
return app
58+
59+
app = create_app()
60+
61+
if __name__ == "__main__":
62+
app.run(debug=True)
63+
```
64+
65+
### Add route to catch data from OneId
66+
67+
```python
68+
@app.route("/params", methods=['GET'])
69+
def params():
70+
print(request.args)
71+
return redirect(url_for('index'))
72+
73+
```
74+
75+
### Use builtin function to convert request args to dict
76+
77+
```python
78+
@app.route("/params", methods=['GET'])
79+
def params():
80+
data = oneid.Params_To_Dict(request.args)
81+
print(data)
82+
return redirect(url_for('index'))
83+
84+
```
85+
86+
### Register your Callback Url for OneID module
87+
88+
```python
89+
with app.test_request_context():
90+
oneid.Set_Callback(url_for('params'))
91+
```
92+
93+
### Full Code
94+
95+
```python
96+
from flask_oneid import OneID
97+
from flask import *
98+
def create_app():
99+
oneid = OneID()
100+
app = Flask(__name__)
101+
app.config.from_pyfile('config.py')
102+
oneid.init_app(app)
103+
104+
@app.route("/", methods=['GET'])
105+
def index():
106+
return "Hello World"
107+
@app.route("/params", methods=['GET'])
108+
def params():
109+
data = oneid.Params_To_Dict(request.args)
110+
return jsonify(data)
111+
112+
with app.test_request_context():
113+
oneid.Set_Callback(url_for('params'))
114+
return app
115+
116+
app = create_app()
117+
118+
if __name__ == "__main__":
119+
app.run(debug=True)
120+
121+
```
122+
123+
### OneID route
124+
125+
After run app go to route `/oneid/login` to login oneid and get data about user
126+
127+
### Return data
128+
129+
Example of data in callback
130+
131+
```json
132+
{
133+
"_pport_expr_date": "",
134+
"_pport_issue_date": "",
135+
"birth_date": "",
136+
"birth_place": "",
137+
"ctzn": "",
138+
"email": "",
139+
"first_name": "",
140+
"full_name": "",
141+
"gd": "",
142+
"legal_info": null,
143+
"mid_name": "",
144+
"mob_phone_no": "",
145+
"natn": "",
146+
"per_adr": "",
147+
"pin": "",
148+
"pport_expr_date": "",
149+
"pport_issue_date": "",
150+
"pport_issue_place": "",
151+
"pport_no": "",
152+
"ret_cd": "",
153+
"sess_id": "",
154+
"sur_name": "",
155+
"tin": "",
156+
"user_id": "",
157+
"user_type": "",
158+
"valid": ""
159+
}
160+
161+
```
162+
163+
U can use it to create user and login with Flask-Admin
164+
165+
## License
166+
167+
This project is licensed under the MIT License (see the `LICENSE` file for details).
168+
169+
170+
"""
12171

13172
setup(
14173
name='Flask-OneID',
15-
version='1.0.1',
174+
version='1.0.3',
16175
url='https://github.com/Odya-LLC/flask_oneid',
17176
license='MIT',
18177
author='odya',

0 commit comments

Comments
 (0)