{"id":38484,"date":"2024-11-01T18:17:27","date_gmt":"2024-11-01T18:17:27","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=38484"},"modified":"2024-11-26T06:44:13","modified_gmt":"2024-11-26T06:44:13","slug":"fastapi-%ec%84%9c%eb%b2%84%ea%b0%9c%eb%b0%9c-oauth2-%eb%b0%8f-jwtjson-web-token-%ec%9d%b8%ec%a6%9d-%ea%b5%ac%ed%98%84","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/38484\/","title":{"rendered":"FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604"},"content":{"rendered":"<p><body><\/p>\n<h2>1. \uac1c\uc694<\/h2>\n<p>FastAPI\ub294 Python\uc73c\ub85c \uc791\uc131\ub41c \ucd5c\uc2e0 \uc6f9 \ud504\ub808\uc784\uc6cc\ud06c\ub85c, \ub9e4\uc6b0 \ube60\ub978 \uc131\ub2a5\uacfc \ud604\ub300\uc801\uc778 \uc6f9 \uac1c\ubc1c\uc758 \ub2e4\uc591\ud55c \uc694\uad6c\ub97c \ucda9\uc871\ud558\uae30 \uc704\ud55c \uac15\ub825\ud55c \uae30\ub2a5\ub4e4\uc744 \uc81c\uacf5\ud569\ub2c8\ub2e4. \ubcf8 \ubb38\uc11c\uc5d0\uc11c\ub294 FastAPI\ub97c \uc0ac\uc6a9\ud558\uc5ec OAuth2 \ubc0f JSON Web Token(JWT) \uc778\uc99d \ubc29\uc2dd\uc744 \uad6c\ud604\ud558\ub294 \ubc29\ubc95\uc744 \uc18c\uac1c\ud558\uace0, \uc774\ub97c \ud1b5\ud574 \uc548\uc804\ud55c API\ub97c \uc124\uacc4\ud558\ub294 \ubc29\ubc95\uc744 \uc0b4\ud3b4\ubcf4\uaca0\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>2. \uc694\uad6c \uc0ac\ud56d<\/h2>\n<p>\ubcf8 \uac15\uc88c\ub97c \uc9c4\ud589\ud558\uae30 \uc704\ud574 \ud544\uc694\ud55c \uc0ac\ud56d\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4:<\/p>\n<ul>\n<li>Python 3.6 \uc774\uc0c1\uc774 \uc124\uce58\ub41c \ud658\uacbd<\/li>\n<li>FastAPI \ub77c\uc774\ube0c\ub7ec\ub9ac \ubc0f \uad00\ub828 \ud328\ud0a4\uc9c0<\/li>\n<li>Uvicorn: ASGI \uc11c\ubc84<\/li>\n<li>Pydantic: \ub370\uc774\ud130 \uac80\uc99d \ubc0f \uc124\uc815 \uad00\ub9ac \ub77c\uc774\ube0c\ub7ec\ub9ac<\/li>\n<\/ul>\n<h2>3. FastAPI \ubc0f \ud544\uc694\ud55c \ud328\ud0a4\uc9c0 \uc124\uce58<\/h2>\n<p>\ucf58\uc194\uc5d0\uc11c \uc544\ub798\uc758 \uba85\ub839\uc5b4\ub97c \uc2e4\ud589\ud558\uc5ec FastAPI\uc640 \ud544\uc694\ud55c \ud328\ud0a4\uc9c0\ub97c \uc124\uce58\ud569\ub2c8\ub2e4:<\/p>\n<pre><code>pip install fastapi uvicorn python-jose passlib[bcrypt]<\/code><\/pre>\n<h2>4. FastAPI \uc11c\ubc84 \uc124\uc815<\/h2>\n<p>FastAPI \uc11c\ubc84\ub97c \uc124\uc815\ud558\ub824\uba74, \uac04\ub2e8\ud55c FastAPI \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ub9cc\ub4e4\uc5b4 \ubcf4\uaca0\uc2b5\ub2c8\ub2e4. \ub2e4\uc74c \ucf54\ub4dc\ub97c \uc0ac\uc6a9\ud558\uc5ec \uae30\ubcf8\uc801\uc778 FastAPI \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc744 \ub9cc\ub4e4\uc5b4 \ubcf4\uc138\uc694:<\/p>\n<pre><code>from fastapi import FastAPI\n\napp = FastAPI()\n\n@app.get(\"\/\")\nasync def read_root():\n    return {\"Hello\": \"World\"}<\/code><\/pre>\n<p>\uc774 \ucf54\ub4dc\ub97c <code>main.py<\/code>\ub77c\ub294 \ud30c\uc77c\ub85c \uc800\uc7a5\ud55c \ud6c4, \ub2e4\uc74c \uba85\ub839\uc5b4\ub85c \uc11c\ubc84\ub97c \uc2e4\ud589\ud569\ub2c8\ub2e4:<\/p>\n<pre><code>uvicorn main:app --reload<\/code><\/pre>\n<p>\uc774\uc81c <code>http:\/\/127.0.0.1:8000<\/code>\ub85c \uc811\uc18d\ud558\uba74 &#8220;Hello World&#8221; \uba54\uc2dc\uc9c0\ub97c \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>5. OAuth2 \ubc0f JWT \uc778\uc99d \ubc29\uc2dd<\/h2>\n<p>OAuth2\ub294 \uc778\uc99d \ubc0f \uad8c\ud55c \ubd80\uc5ec\ub97c \uc704\ud55c \ud504\ub85c\ud1a0\ucf5c\ub85c, \uc0ac\uc6a9\uc790\uac00 \ub9ac\uc18c\uc2a4\uc5d0 \uc811\uadfc\ud560 \uc218 \uc788\ub3c4\ub85d \uad8c\ud55c\uc744 \ubd80\uc5ec\ud558\ub294 \ubc29\uc2dd\uc785\ub2c8\ub2e4. JWT\ub294 \uc138\uc158 \uc815\ubcf4\ub97c \uc800\uc7a5\ud560 \uc218 \uc788\ub294 JSON \uac1d\uccb4\ub85c, \ub2e4\uc591\ud55c \uc815\ubcf4\ub97c \ub2f4\uc744 \uc218 \uc788\uc73c\uba70, \uc11c\uba85\uc744 \ud1b5\ud574 \ub370\uc774\ud130\uc758 \ubb34\uacb0\uc131\uc744 \ud655\uc778\ud560 \uc218 \uc788\ub294 \uc7a5\uc810\uc774 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>6. \uc0ac\uc6a9\uc790 \uc778\uc99d \ubc0f JWT \uc0dd\uc131<\/h2>\n<p>\ud68c\uc6d0 \uac00\uc785 \ubc0f \ub85c\uadf8\uc778\uc744 \uad6c\ud604\ud560 \ud544\uc694\uac00 \uc788\uc2b5\ub2c8\ub2e4. \ub2e4\uc74c \uc608\uc81c\ub294 \uc0ac\uc6a9\uc790 \uc815\ubcf4\ub97c \uc800\uc7a5\ud558\uae30 \uc704\ud55c Pydantic \ubaa8\ub378\uacfc JWT \uc0dd\uc131\uc744 \uc704\ud55c \ubc29\ubc95\uc744 \ubcf4\uc5ec\uc90d\ub2c8\ub2e4:<\/p>\n<pre><code>from fastapi import Depends, HTTPException, status\nfrom fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm\nfrom jose import JWTError, jwt\nfrom datetime import datetime, timedelta\nfrom pydantic import BaseModel\nfrom passlib.context import CryptContext\n\n# \ube44\ubc00 \ud0a4\uc640 \uc54c\uace0\ub9ac\uc998 \uc124\uc815\nSECRET_KEY = \"your-secret-key\"\nALGORITHM = \"HS256\"\nACCESS_TOKEN_EXPIRE_MINUTES = 30\n\n# \ube44\ubc00\ubc88\ud638 \uc554\ud638\ud654 \uc124\uc815\npwd_context = CryptContext(schemes=[\"bcrypt\"], deprecated=\"auto\")\n\n# \uc0ac\uc6a9\uc790 \ubaa8\ub378\nclass User(BaseModel):\n    username: str\n    email: str | None = None\n    full_name: str | None = None\n    disabled: bool | None = None\n\n# \ub85c\uadf8\uc778 \uc0ac\uc6a9\uc790 \ubaa8\ub378\nclass UserInDB(User):\n    hashed_password: str\n\n# OAuth2PasswordBearer \uc778\uc2a4\ud134\uc2a4 \uc0dd\uc131\noauth2_scheme = OAuth2PasswordBearer(tokenUrl=\"token\")\n\n# \uc0ac\uc6a9\uc790 \ub370\uc774\ud130 \uc800\uc7a5\uc18c (\uc608: \ub370\uc774\ud130\ubca0\uc774\uc2a4 \ub300\uc2e0 \uc0ac\uc6a9)\nfake_users_db = {\n    \"johndoe\": {\n        \"username\": \"johndoe\",\n        \"full_name\": \"John Doe\",\n        \"email\": \"johndoe@example.com\",\n        \"hashed_password\": pwd_context.hash(\"password\"),\n        \"disabled\": False,\n    }\n}\n\n# \ube44\ubc00\ubc88\ud638 \uac80\uc99d \ud568\uc218\ndef verify_password(plain_password, hashed_password):\n    return pwd_context.verify(plain_password, hashed_password)\n\n# \uc0ac\uc6a9\uc790 \uc870\ud68c \ud568\uc218\ndef get_user(db, username: str):\n    if username in db:\n        user_dict = db[username]\n        return UserInDB(**user_dict)\n\n# JWT \uc0dd\uc131 \ud568\uc218\ndef create_access_token(data: dict, expires_delta: timedelta | None = None):\n    to_encode = data.copy()\n    if expires_delta:\n        expire = datetime.utcnow() + expires_delta\n    else:\n        expire = datetime.utcnow() + timedelta(minutes=15)\n    to_encode.update({\"exp\": expire})\n    encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)\n    return encoded_jwt\n\n# FastAPI \uc571 \uc124\uc815\napp = FastAPI()\n\n@app.post(\"\/token\")\nasync def login(form_data: OAuth2PasswordRequestForm = Depends()):\n    user = get_user(fake_users_db, form_data.username)\n    if not user or not verify_password(form_data.password, user.hashed_password):\n        raise HTTPException(\n            status_code=status.HTTP_401_UNAUTHORIZED,\n            detail=\"\uc798\ubabb\ub41c \uc0ac\uc6a9\uc790\uba85 \ub610\ub294 \ube44\ubc00\ubc88\ud638\",\n            headers={\"WWW-Authenticate\": \"Bearer\"},\n        )\n    access_token_expires = timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)\n    access_token = create_access_token(\n        data={\"sub\": user.username}, expires_delta=access_token_expires\n    )\n    return {\"access_token\": access_token, \"token_type\": \"bearer\"}<\/code><\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\ub97c \ud1b5\ud574 \ub85c\uadf8\uc778 \uc5d4\ub4dc\ud3ec\uc778\ud2b8\uac00 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \uc0ac\uc6a9\uc790\ub294 \uc0ac\uc6a9\uc790\uba85\uc744 \uc785\ub825\ud558\uace0 \ube44\ubc00\ubc88\ud638\ub97c \uc81c\uacf5\ud558\uc5ec JWT\ub97c \ubc1b\uc744 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>7. JWT \uc778\uc99d\uc774 \ud544\uc694\ud55c \uc5d4\ub4dc\ud3ec\uc778\ud2b8<\/h2>\n<p>\uc778\uc99d\uc774 \ud544\uc694\ud55c API \uc5d4\ub4dc\ud3ec\uc778\ud2b8\ub97c \ub9cc\ub4e4\uae30 \uc704\ud574 FastAPI\uc758 \uc885\uc18d\uc131\uc744 \ud65c\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \ub2e4\uc74c\uc740 JWT\uac00 \ud544\uc694\ud55c API \uc5d4\ub4dc\ud3ec\uc778\ud2b8\ub97c \ub9cc\ub4dc\ub294 \ubc29\ubc95\uc785\ub2c8\ub2e4:<\/p>\n<pre><code>from fastapi import Security\n\ndef get_current_user(token: str = Depends(oauth2_scheme)):\n    credentials_exception = HTTPException(\n        status_code=status.HTTP_401_UNAUTHORIZED,\n        detail=\"\uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 \ud1a0\ud070\",\n        headers={\"WWW-Authenticate\": \"Bearer\"},\n    )\n    try:\n        payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])\n        username: str = payload.get(\"sub\")\n        if username is None:\n            raise credentials_exception\n        token_data = User(username=username)\n    except JWTError:\n        raise credentials_exception\n    user = get_user(fake_users_db, username=token_data.username)\n    if user is None:\n        raise credentials_exception\n    return user\n\n@app.get(\"\/users\/me\", response_model=User)\nasync def read_users_me(current_user: User = Depends(get_current_user)):\n    return current_user<\/code><\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\uc5d0\uc11c\ub294 <code>\/users\/me<\/code> \uc5d4\ub4dc\ud3ec\uc778\ud2b8\ub97c \ub9cc\ub4e4\uc5b4 \uad8c\ud55c\uc774 \uc788\ub294 \uacbd\uc6b0\uc5d0\ub9cc \uc0ac\uc6a9\uc790\uac00 \ubcf8\uc778\uc758 \uc815\ubcf4\ub97c \uc870\ud68c\ud560 \uc218 \uc788\ub3c4\ub85d \uc124\uc815\ud588\uc2b5\ub2c8\ub2e4.<\/p>\n<h2>8. \uc804\uccb4 \ucf54\ub4dc<\/h2>\n<p>\uc774\uc81c\uae4c\uc9c0 \uad6c\ud604\ud55c \uc804\uccb4 \ucf54\ub4dc\ub97c \uc815\ub9ac\ud558\uba74 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4:<\/p>\n<pre><code>from fastapi import FastAPI, Depends, HTTPException, status\nfrom fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm\nfrom jose import JWTError, jwt\nfrom datetime import datetime, timedelta\nfrom pydantic import BaseModel\nfrom passlib.context import CryptContext\n\nSECRET_KEY = \"your-secret-key\"\nALGORITHM = \"HS256\"\nACCESS_TOKEN_EXPIRE_MINUTES = 30\n\npwd_context = CryptContext(schemes=[\"bcrypt\"], deprecated=\"auto\")\n\nclass User(BaseModel):\n    username: str\n    email: str | None = None\n    full_name: str | None = None\n    disabled: bool | None = None\n\nclass UserInDB(User):\n    hashed_password: str\n\noauth2_scheme = OAuth2PasswordBearer(tokenUrl=\"token\")\n\nfake_users_db = {\n    \"johndoe\": {\n        \"username\": \"johndoe\",\n        \"full_name\": \"John Doe\",\n        \"email\": \"johndoe@example.com\",\n        \"hashed_password\": pwd_context.hash(\"password\"),\n        \"disabled\": False,\n    }\n}\n\ndef verify_password(plain_password, hashed_password):\n    return pwd_context.verify(plain_password, hashed_password)\n\ndef get_user(db, username: str):\n    if username in db:\n        user_dict = db[username]\n        return UserInDB(**user_dict)\n\ndef create_access_token(data: dict, expires_delta: timedelta | None = None):\n    to_encode = data.copy()\n    if expires_delta:\n        expire = datetime.utcnow() + expires_delta\n    else:\n        expire = datetime.utcnow() + timedelta(minutes=15)\n    to_encode.update({\"exp\": expire})\n    encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)\n    return encoded_jwt\n\napp = FastAPI()\n\n@app.post(\"\/token\")\nasync def login(form_data: OAuth2PasswordRequestForm = Depends()):\n    user = get_user(fake_users_db, form_data.username)\n    \n    if not user or not verify_password(form_data.password, user.hashed_password):\n        raise HTTPException(\n            status_code=status.HTTP_401_UNAUTHORIZED,\n            detail=\"\uc798\ubabb\ub41c \uc0ac\uc6a9\uc790\uba85 \ub610\ub294 \ube44\ubc00\ubc88\ud638\",\n            headers={\"WWW-Authenticate\": \"Bearer\"},\n        )\n    \n    access_token_expires = timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)\n    access_token = create_access_token(data={\"sub\": user.username}, expires_delta=access_token_expires)\n    return {\"access_token\": access_token, \"token_type\": \"bearer\"}\n\ndef get_current_user(token: str = Depends(oauth2_scheme)):\n    credentials_exception = HTTPException(\n        status_code=status.HTTP_401_UNAUTHORIZED,\n        detail=\"\uc720\ud6a8\ud558\uc9c0 \uc54a\uc740 \ud1a0\ud070\",\n        headers={\"WWW-Authenticate\": \"Bearer\"},\n    )\n    try:\n        payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])\n        username: str = payload.get(\"sub\")\n        if username is None:\n            raise credentials_exception\n        token_data = User(username=username)\n    except JWTError:\n        raise credentials_exception\n    user = get_user(fake_users_db, username=token_data.username)\n    if user is None:\n        raise credentials_exception\n    return user\n\n@app.get(\"\/users\/me\", response_model=User)\nasync def read_users_me(current_user: User = Depends(get_current_user)):\n    return current_user <\/code><\/pre>\n<h2>9. \ub9c8\ubb34\ub9ac<\/h2>\n<p>\uc774\uc81c FastAPI\ub97c \uc0ac\uc6a9\ud558\uc5ec OAuth2\uc640 JWT\ub97c \ud65c\uc6a9\ud55c \uc778\uc99d \uae30\ub2a5\uc744 \uad6c\ud604\ud558\ub294 \ubc29\ubc95\uc744 \uc54c\uc544\ubcf4\uc558\uc2b5\ub2c8\ub2e4. \uc774 \uc608\uc81c\ub97c \ubc14\ud0d5\uc73c\ub85c \uc2e4\uc81c \uc560\ud50c\ub9ac\ucf00\uc774\uc158\uc5d0 \ud544\uc694\ud55c \uc778\uc99d \ubc0f \uad8c\ud55c \ubd80\uc5ec \ub85c\uc9c1\uc744 \ucd94\uac00\ud558\uc5ec, \ubcf4\ub2e4 \uc548\uc804\ud55c API\ub97c \uc124\uacc4\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. FastAPI\uc758 \ub6f0\uc5b4\ub09c \uc131\ub2a5\uacfc \uac04\ud3b8\ud55c \uc0ac\uc6a9\ubc95 \ub355\ubd84\uc5d0 \uc6f9 \uc11c\ube44\uc2a4 \uac1c\ubc1c\uc774 \ud6e8\uc52c \uc218\uc6d4\ud574\uc9c8 \uac83\uc785\ub2c8\ub2e4.<\/p>\n<p>\uc774 \uae00\uc774 FastAPI\uc640 OAuth2, JWT \uc778\uc99d\uc744 \uc774\ud574\ud558\ub294 \ub370 \ub3c4\uc6c0\uc774 \ub418\uc5c8\uae30\ub97c \ubc14\ub78d\ub2c8\ub2e4. \ub354 \ub098\uc544\uac00 FastAPI\uc758 \ub2e4\uc591\ud55c \uae30\ub2a5\uc744 \ud0d0\uc0c9\ud558\uc2dc\uae30\ub97c \uad8c\uc7a5\ud569\ub2c8\ub2e4.<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \uac1c\uc694 FastAPI\ub294 Python\uc73c\ub85c \uc791\uc131\ub41c \ucd5c\uc2e0 \uc6f9 \ud504\ub808\uc784\uc6cc\ud06c\ub85c, \ub9e4\uc6b0 \ube60\ub978 \uc131\ub2a5\uacfc \ud604\ub300\uc801\uc778 \uc6f9 \uac1c\ubc1c\uc758 \ub2e4\uc591\ud55c \uc694\uad6c\ub97c \ucda9\uc871\ud558\uae30 \uc704\ud55c \uac15\ub825\ud55c \uae30\ub2a5\ub4e4\uc744 \uc81c\uacf5\ud569\ub2c8\ub2e4. \ubcf8 \ubb38\uc11c\uc5d0\uc11c\ub294 FastAPI\ub97c \uc0ac\uc6a9\ud558\uc5ec OAuth2 \ubc0f JSON Web Token(JWT) \uc778\uc99d \ubc29\uc2dd\uc744 \uad6c\ud604\ud558\ub294 \ubc29\ubc95\uc744 \uc18c\uac1c\ud558\uace0, \uc774\ub97c \ud1b5\ud574 \uc548\uc804\ud55c API\ub97c \uc124\uacc4\ud558\ub294 \ubc29\ubc95\uc744 \uc0b4\ud3b4\ubcf4\uaca0\uc2b5\ub2c8\ub2e4. 2. \uc694\uad6c \uc0ac\ud56d \ubcf8 \uac15\uc88c\ub97c \uc9c4\ud589\ud558\uae30 \uc704\ud574 \ud544\uc694\ud55c \uc0ac\ud56d\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4: Python 3.6 &hellip; <a href=\"https:\/\/atmokpo.com\/w\/38484\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[183],"tags":[],"class_list":["post-38484","post","type-post","status-publish","format-standard","hentry","category-fastapi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/38484\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"1. \uac1c\uc694 FastAPI\ub294 Python\uc73c\ub85c \uc791\uc131\ub41c \ucd5c\uc2e0 \uc6f9 \ud504\ub808\uc784\uc6cc\ud06c\ub85c, \ub9e4\uc6b0 \ube60\ub978 \uc131\ub2a5\uacfc \ud604\ub300\uc801\uc778 \uc6f9 \uac1c\ubc1c\uc758 \ub2e4\uc591\ud55c \uc694\uad6c\ub97c \ucda9\uc871\ud558\uae30 \uc704\ud55c \uac15\ub825\ud55c \uae30\ub2a5\ub4e4\uc744 \uc81c\uacf5\ud569\ub2c8\ub2e4. \ubcf8 \ubb38\uc11c\uc5d0\uc11c\ub294 FastAPI\ub97c \uc0ac\uc6a9\ud558\uc5ec OAuth2 \ubc0f JSON Web Token(JWT) \uc778\uc99d \ubc29\uc2dd\uc744 \uad6c\ud604\ud558\ub294 \ubc29\ubc95\uc744 \uc18c\uac1c\ud558\uace0, \uc774\ub97c \ud1b5\ud574 \uc548\uc804\ud55c API\ub97c \uc124\uacc4\ud558\ub294 \ubc29\ubc95\uc744 \uc0b4\ud3b4\ubcf4\uaca0\uc2b5\ub2c8\ub2e4. 2. \uc694\uad6c \uc0ac\ud56d \ubcf8 \uac15\uc88c\ub97c \uc9c4\ud589\ud558\uae30 \uc704\ud574 \ud544\uc694\ud55c \uc0ac\ud56d\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4: Python 3.6 &hellip; \ub354 \ubcf4\uae30 &quot;FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/38484\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T18:17:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-26T06:44:13+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/38484\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/38484\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604\",\"datePublished\":\"2024-11-01T18:17:27+00:00\",\"dateModified\":\"2024-11-26T06:44:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/38484\/\"},\"wordCount\":51,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"FastAPI\uc11c\ubc84\uac1c\ubc1c\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/38484\/\",\"url\":\"https:\/\/atmokpo.com\/w\/38484\/\",\"name\":\"FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T18:17:27+00:00\",\"dateModified\":\"2024-11-26T06:44:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/38484\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/38484\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/38484\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/38484\/","og_locale":"ko_KR","og_type":"article","og_title":"FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"1. \uac1c\uc694 FastAPI\ub294 Python\uc73c\ub85c \uc791\uc131\ub41c \ucd5c\uc2e0 \uc6f9 \ud504\ub808\uc784\uc6cc\ud06c\ub85c, \ub9e4\uc6b0 \ube60\ub978 \uc131\ub2a5\uacfc \ud604\ub300\uc801\uc778 \uc6f9 \uac1c\ubc1c\uc758 \ub2e4\uc591\ud55c \uc694\uad6c\ub97c \ucda9\uc871\ud558\uae30 \uc704\ud55c \uac15\ub825\ud55c \uae30\ub2a5\ub4e4\uc744 \uc81c\uacf5\ud569\ub2c8\ub2e4. \ubcf8 \ubb38\uc11c\uc5d0\uc11c\ub294 FastAPI\ub97c \uc0ac\uc6a9\ud558\uc5ec OAuth2 \ubc0f JSON Web Token(JWT) \uc778\uc99d \ubc29\uc2dd\uc744 \uad6c\ud604\ud558\ub294 \ubc29\ubc95\uc744 \uc18c\uac1c\ud558\uace0, \uc774\ub97c \ud1b5\ud574 \uc548\uc804\ud55c API\ub97c \uc124\uacc4\ud558\ub294 \ubc29\ubc95\uc744 \uc0b4\ud3b4\ubcf4\uaca0\uc2b5\ub2c8\ub2e4. 2. \uc694\uad6c \uc0ac\ud56d \ubcf8 \uac15\uc88c\ub97c \uc9c4\ud589\ud558\uae30 \uc704\ud574 \ud544\uc694\ud55c \uc0ac\ud56d\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4: Python 3.6 &hellip; \ub354 \ubcf4\uae30 \"FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604\"","og_url":"https:\/\/atmokpo.com\/w\/38484\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T18:17:27+00:00","article_modified_time":"2024-11-26T06:44:13+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/38484\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/38484\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604","datePublished":"2024-11-01T18:17:27+00:00","dateModified":"2024-11-26T06:44:13+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/38484\/"},"wordCount":51,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["FastAPI\uc11c\ubc84\uac1c\ubc1c"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/38484\/","url":"https:\/\/atmokpo.com\/w\/38484\/","name":"FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T18:17:27+00:00","dateModified":"2024-11-26T06:44:13+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/38484\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/38484\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/38484\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"FastAPI \uc11c\ubc84\uac1c\ubc1c, OAuth2 \ubc0f JWT(JSON Web Token) \uc778\uc99d \uad6c\ud604"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/38484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=38484"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/38484\/revisions"}],"predecessor-version":[{"id":38485,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/38484\/revisions\/38485"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=38484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=38484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=38484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}