게시물 등록 및 토큰검증 후 등록 추가
This commit is contained in:
13
blog/utils.py
Normal file
13
blog/utils.py
Normal file
@ -0,0 +1,13 @@
|
||||
import requests
|
||||
from rest_framework.exceptions import AuthenticationFailed
|
||||
|
||||
def verify_token_with_auth_server(token: str):
|
||||
# url = "http://192.168.0.202:8000/api/auth/verify/"
|
||||
url = settings.AUTH_VERIFY_URL # ✅ .env에서 설정한 값 사용
|
||||
headers = {"Content-Type": "application/json"}
|
||||
try:
|
||||
response = requests.post(url, json={"token": token}, headers=headers, timeout=3)
|
||||
if response.status_code != 200:
|
||||
raise AuthenticationFailed("유효하지 않은 토큰입니다 (auth 서버 응답 오류)")
|
||||
except requests.exceptions.RequestException as e:
|
||||
raise AuthenticationFailed(f"auth 서버 통신 실패: {str(e)}")
|
Reference in New Issue
Block a user