Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

melihcolpan/flask-login-example

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

113 Commits
113 Commits
 
 
 
 
 
 
 
 
 
 

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=example@example.com
Login:
http POST :5000/v1/auth/login email=example@example.com 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=test_email@example.com password=test_password
Admin login:
http POST :5000/v1/auth/login email=admin_email@example.com password=admin_password
Super admin login:
http POST :5000/v1/auth/login email=sa_email@example.com 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 emails==test_email@example.com,admin_email@example.com 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":"example@example.com"}' http://localhost:5000/v1/auth/register
Login:
curl -H "Content-Type: application/json" --data '{"email":"example@example.com", "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":"test_email@example.com"}' http://localhost:5000/v1/auth/login
Admin login:
curl -H "Content-Type: application/json" --data '{"password":"admin_password", "email":"admin_email@example.com"}' http://localhost:5000/v1/auth/login
Super admin login:
curl -H "Content-Type: application/json" --data '{"password":"sa_password", "email":"sa_email@example.com"}' 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&emails=test_email@example.com,admin_email@example.com&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

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.