๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

๐Ÿ•ธ๏ธ URL ์—ฐ๊ฒฐ ์™ธ๋ถ€์ž๋ฃŒ ๊ฐœ๋ฐœ ๊ฐ€์ด๋“œ

์ด ํŽ˜์ด์ง€์—์„œ๋Š” ์™ธ๋ถ€ํ•™์Šต์ž๋ฃŒ ์„ค์ • ๋ฐฉ๋ฒ• ๋ฐ ๊ฐœ๋ฐœ ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

URL ์—ฐ๊ฒฐ ์™ธ๋ถ€์ž๋ฃŒ ์„ค์ •โ€‹

์ˆ˜์—…์—์„œ ์ž๋ฃŒ ์ถ”๊ฐ€ ๋ฒ„ํŠผ์„ ํด๋ฆญ ํ›„ URL ์—ฐ๊ฒฐ ์™ธ๋ถ€์ž๋ฃŒ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

์œ„์™€ ๊ฐ™์ด ์„ ํƒํ•˜๊ณ  ์ž๋ฃŒ๋ฅผ ๋กœ๋“œํ•˜๋ฉด iframe ์„ ํ†ตํ•ด ์™ธ๋ถ€ ์ž๋ฃŒ URL ์— ์ž…๋ ฅ๋œ ์ฃผ์†Œ๊ฐ€ ๋กœ๋“œ๋ฉ๋‹ˆ๋‹ค. ์ด ๋•Œ, URL์€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ค์ •๋ฉ๋‹ˆ๋‹ค.

https://example.com?extToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9โ€ฆ

์ฑ„์  API๋ฅผ ์ด์šฉํ•œ ์ ์ˆ˜ ๋ถ€์—ฌ ๋ฐฉ๋ฒ•โ€‹

์œ ์ €๊ฐ€ ์ ‘์†ํ•˜๋ฉฐ query parameter๋กœ ํ•จ๊ป˜ ๋„˜๊ฒจ์ค€ extToken์„ decode ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ payload๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

{
"user_id": 917678,
"uid": null,
"progress_url": "https://api-esp-proxy.elice.io/default/progress/external?token=eyJhbGciOiJIUz...",
"token_nonce": null,
"ts": 1696408550682,
"iss": "elice-api",
"tutor_user_id": 111 # ํŠœํ„ฐ๋ง ๋ชจ๋“œ์ธ ๊ฒฝ์šฐ์—๋งŒ ํ•ด๋‹น ๊ฐ’์ด ์žˆ์Œ
}

ํ•ด๋‹น ๊ฐ’์ค‘ progress_url์— ์•„๋ž˜์™€ ๊ฐ™์ด ์š”์ฒญ์„ ๋ณด๋‚ด๋ฉด, ์ฑ„์ ์ด ์™„๋ฃŒ๋ฉ๋‹ˆ๋‹ค.

  • Method: POST

  • Url: {progress_url}

  • Body

    {
    "score": 100
    }
  • Python code ์˜ˆ์‹œ

    progress_url = decoded_token["progress_url"]

    response = requests.post(
    progress_url,
    json={"score": reqeust.score},
    )

ํŠœํ„ฐ๋ง ๋ชจ๋“œ ์—ฌ๋ถ€ ํ™•์ธ ๋ฐฉ๋ฒ•โ€‹

์œ ์ €๊ฐ€ ์ ‘์†ํ•˜๋ฉฐ query parameter๋กœ ํ•จ๊ป˜ ๋„˜๊ฒจ์ค€ extToken์„ decode ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ payload๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

{
"user_id": 917678,
"uid": null,
"progress_url": "<https://api-esp-proxy.elice.io/default/progress/external?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOm51bGwsInVzZXJfaWQiOjEzMTg5NDA0LCJvcmdhbml6YXRpb25faWQiOjM0ODQsImNvdXJzZV9pZCI6Nzg4MzksImxlY3R1cmVfcGFnZV9pZCI6NzE2NjM2N30.ULsamRseUwE-6gFI5YwQscn4RwAXMBzpWggKKlv1-1o>",
"token_nonce": null,
"ts": 1696408550682,
"iss": "elice-api",
"tutor_user_id": 48374
}

ํ•ด๋‹น payload์—์„œ tutor_user_id ๊ฐ€ ์กด์žฌํ•˜๋ฉด ํŠœํ„ฐ๋ง ๋ชจ๋“œ, ์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด ํ•™์ƒ ๋ชจ๋“œ์ž…๋‹ˆ๋‹ค.