Skip to content

melihcolpan/flask-login-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flask-restful-login-example

####INSTALLATION

git clone https://github.com/melihcolpan/flask-restful-login
cd flask-login-example
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
python -m main

For requests using httpie: https://github.com/jkbrzt/httpie

Register:
http POST :5000/v1/auth/register username=example_username password=example_password [email protected]
Login:
http POST :5000/v1/auth/login [email protected] password=example_password
Response: Got access token and refresh token!
Logout:
http POST :5000/v1/auth/logout Authorization:"bearer ACCESS_TOKEN" refresh_token=REFRESH_TOKEN
Note: Test user and admin users are created in database initializer class.
User login:
http POST :5000/v1/auth/login [email protected] password=test_password
Admin login:
http POST :5000/v1/auth/login [email protected] password=admin_password
Super admin login:
http POST :5000/v1/auth/login [email protected] password=sa_password
Super admin requiring authentication example handlers
NOT YET
http GET :5000/user_add Authorization:"bearer ACCESS_TOKEN"

NOT YET
http GET :5000/users Authorization:"Bearer ACCESS_TOKEN" usernames==test_username,admin_username [email protected],[email protected] start_date==01.01.1993 end_date==01.01.2050
Admin requiring authentication example handlers
NOT YET
http GET :5000/data_admin Authorization:"Bearer ACCESS_TOKEN"
User requiring authentication handler
NOT YET
http GET :5000/data_user Authorization:"Bearer ACCESS_TOKEN"

For requests using curl: https://curl.haxx.se/download.html

Register:
curl -H "Content-Type: application/json" --data '{"username":"example_name","password":"example_password", "email":"[email protected]"}' http://localhost:5000/v1/auth/register
Login:
curl -H "Content-Type: application/json" --data '{"email":"[email protected]", "password":"example_password"}' http://localhost:5000/v1/auth/login
Response: Got access token and refresh token!
Logout:
curl -H "Content-Type: application/json" -H "Authorization: Bearer ACCESS_TOKEN" --data '{"refresh_token":"REFRESH_TOKEN"}' http://localhost:5000/v1/auth/logout
Note: Test user and admin users are created in database initializer class.
User login:
curl -H "Content-Type: application/json" --data '{"password":"test_password", "email":"[email protected]"}' http://localhost:5000/v1/auth/login
Admin login:
curl -H "Content-Type: application/json" --data '{"password":"admin_password", "email":"[email protected]"}' http://localhost:5000/v1/auth/login
Super admin login:
curl -H "Content-Type: application/json" --data '{"password":"sa_password", "email":"[email protected]"}' http://localhost:5000/v1/auth/login
Test super admin requiring authentication example handlers
NOT YET
curl -H "Content-Type: application/json" -H "Authorization: Bearer ACCESS_TOKEN" http://localhost:5000/user_add

NOT YET
curl -X GET 'localhost:5000/users?usernames=test_username,admin_username&[email protected],[email protected]&start_date=01.01.1993&end_date=01.01.2050' -H "Content-Type: application/json" -H "Authorization: Bearer ACCESS_TOKEN" 
Test admin requiring authentication example handlers
NOT YET
curl -H "Content-Type: application/json" -H "Authorization: Bearer ACCESS_TOKEN" http://localhost:5000/data_admin
Test user requiring authentication handler
NOT YET
curl -H "Content-Type: application/json" -H "Authorization: Bearer ACCESS_TOKEN" http://localhost:5000/data_user

About

flask-sqlalchemy-marshmallow-login-example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages