https://github.com/odya-llc/flask_oneid
OneID integration for Flask (only Uzbekistan)
https://github.com/odya-llc/flask_oneid
flask flask-oneid integration odya uzbekistan
Last synced: about 2 months ago
JSON representation
OneID integration for Flask (only Uzbekistan)
- Host: GitHub
- URL: https://github.com/odya-llc/flask_oneid
- Owner: Odya-LLC
- License: mit
- Created: 2022-06-04T22:37:54.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-08T10:56:37.000Z (almost 3 years ago)
- Last Synced: 2025-03-19T12:47:30.090Z (2 months ago)
- Topics: flask, flask-oneid, integration, odya, uzbekistan
- Language: Python
- Homepage:
- Size: 19.5 KB
- Stars: 13
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# Flask-OneID




> Only for UzbekistanOneID integration for Flask application
## Links
* [About OneID](https://id.egov.uz/)
* [Examples](https://github.com/Odya-LLC/flask_oneid/tree/main/examples)## How it Works
### Install
```
pip install Flask-OneID
```### Add your credentials from OneID to config file
```python
ONEID_LOGIN = "your login"
ONEID_PASSWORD = "your pasword"
ONEID_URL = "url from OneID" # defaul https://sso.egov.uz/sso/oauth/Authorization.do```
### Create Flask App With OneID
```python
from flask_oneid import OneID
from flask import *
def create_app():
oneid = OneID()
app = Flask(__name__)
app.config.from_pyfile('config.py')
oneid.init_app(app)
@app.route("/", methods=['GET'])
def index():
return "Hello World"
return appapp = create_app()
if __name__ == "__main__":
app.run(debug=True)
```### Add route to catch data from OneId
```python
@app.route("/params", methods=['GET'])
def params():
print(request.args)
return redirect(url_for('index'))```
### Use builtin function to convert request args to dict
```python
@app.route("/params", methods=['GET'])
def params():
data = oneid.Params_To_Dict(request.args)
print(data)
return redirect(url_for('index'))```
### Register your Callback Url for OneID module
```python
with app.test_request_context():
oneid.Set_Callback(url_for('params'))
```### Full Code
```python
from flask_oneid import OneID
from flask import *
def create_app():
oneid = OneID()
app = Flask(__name__)
app.config.from_pyfile('config.py')
oneid.init_app(app)
@app.route("/", methods=['GET'])
def index():
return "Hello World"
@app.route("/params", methods=['GET'])
def params():
data = oneid.Params_To_Dict(request.args)
return jsonify(data)
with app.test_request_context():
oneid.Set_Callback(url_for('params'))
return appapp = create_app()
if __name__ == "__main__":
app.run(debug=True)```
### OneID route
After run app go to route `/oneid/login` to login oneid and get data about user
### Return data
Example of data in callback
```json
{
"_pport_expr_date": "",
"_pport_issue_date": "",
"birth_date": "",
"birth_place": "",
"ctzn": "",
"email": "",
"first_name": "",
"full_name": "",
"gd": "",
"legal_info": null,
"mid_name": "",
"mob_phone_no": "",
"natn": "",
"per_adr": "",
"pin": "",
"pport_expr_date": "",
"pport_issue_date": "",
"pport_issue_place": "",
"pport_no": "",
"ret_cd": "",
"sess_id": "",
"sur_name": "",
"tin": "",
"user_id": "",
"user_type": "",
"valid": ""
}```
U can use it to create user and login with Flask-Admin
## License
This project is licensed under the MIT License (see the `LICENSE` file for details).