RestFul API

JWT ์ธ์ฆ ํ† ํฐ์˜ ๋กœ๊ทธ์ธ ๋งŒ๋ฃŒ ์‹œ๊ฐ„ ์„ค์ •ํ•˜๊ธฐ

567Rabbit 2024. 5. 22. 17:05

https://codebunny99.tistory.com/100

 

JWT(JSON WEP TOKEN) ์•”ํ˜ธํ™” ๋กœ๊ทธ์ธ API ๋งŒ๋“ค๊ธฐ

๋กœ๊ทธ์ธ API ๋งŒ๋“ค๊ธฐ     app.py์— ์‚ฝ์ž…ํ•˜๊ธฐfrom resources.user import UserLoginResourceapi.add_resource( UserLoginResource, '/users/login')    user.py์— ์‚ฝ์ž…ํ•˜๊ธฐfrom utils import check_password #4์—์„œ ์‚ฝ์ž…class UserLoginResource(Re

codebunny99.tistory.com

 

๋กœ๊ทธ์ธ API ๋งŒ๋“ค๊ธฐ๋Š” ์œ„ ๊ธ€์„ ์ฐธ์กฐํ•˜์„ธ์š”

 

 

 

๋กœ๊ทธ์ธ ํ† ํฐ์˜ ๋งŒ๋ฃŒ ์‹œ๊ฐ„ ์„ค์ •

 

 

user.py ํŒŒ์ผ ์ˆ˜์ •ํ•˜๊ธฐ

 

 

class UserLoginResource

 

bash
๋‹ซ๊ธฐ
import datetime # ์ˆ˜์ • # 6. ์‹œ๊ฐ„ ์ถ”๊ฐ€ access_token = create_access_token(user_id, expires_delta= datetime.timedelta(minutes=3))

 

 

 

 

class UserRegisterResource

 

bash
๋‹ซ๊ธฐ
import datetime # ์ˆ˜์ • ### 6-2. ์‹œ๊ฐ„ ์ถ”๊ฐ€ access_token = create_access_token(user_id, expires_delta= datetime.timedelta(minutes=3))

 

 

 

 

config.py ์ˆ˜์ •ํ•˜๊ธฐ

 

 

True๋กœ ๋ณ€๊ฒฝ