[Airflow Error] 403:Forbidden

2022. 9. 8. 23:26ใ†๐Ÿ›  Data Engineering/Apache Airflow

 

403 Forbidden

HTTP ์˜ค๋ฅ˜ ์ฝ”๋“œ

URL์„ ๋“ค์–ด๊ฐ€๊ฑฐ๋‚˜, API๋ฅผ ์š”์ฒญํ•˜๋˜ ์ค‘ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์—๋Ÿฌ๋ฅผ ๋งŒ๋‚ฌ๋‚˜์š”?

๊ทธ๋ ‡๋‹ค๋ฉด ์—ฌ๋Ÿฌ๋ถ„์€ ์ •์ƒ์ ์ธ ์š”์ฒญ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค๋งŒ, ์ €์ชฝ์˜ ์„œ๋ฒ„๊ฐ€ ๊ฑฐ๋ถ€ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์—ฌ๋Ÿฌ๋ถ„์ด ํ•ด์•ผํ•  ๊ฒƒ์€, ์ด๊ฒƒ์ €๊ฒƒ ์ฝ”๋“œ ์—๋Ÿฌ๋ฅผ ์ฐพ๊ธฐ ๋ณด๋‹จ, ํ•ด๋‹น url์˜ ์‚ฌ์ดํŠธ๊ฐ€ ์›ํ•˜๋Š” ๊ถŒํ•œ์„ ๋ถ€์—ฌ๋ฐ›์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด api key๋ฅผ ๋ฐ›๊ฑฐ๋‚˜, authentication ๋ฃฐ์„ ์‚ดํŽด๋ณด๊ณ  ๋”ฐ๋ผํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. 

 

 

์ €์˜ ๊ฒฝ์šฐ, 

Airflow Task ์ค‘ opensea api ์œ ๋ฌด๋ฅผ ํ™•์ธํ•˜๋Š” ์„ผ์„œ๋ฅผ ๊ฐœ๋ฐœํ•˜๊ณ  ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๋‹น์—ฐํžˆ opensea api URL์„ ํƒ€๊ณ  ํ™•์ธํ•˜๋Š” ์ž‘์—…์ด ์ปดํ“จํ„ฐ์—์„œ ์ด๋ค„์งˆ ๊ฒƒ์ด๊ณ , ๊ทธ๋Ÿฌ๋‹ค๊ฐ€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜๋ฅผ ๋ƒˆ์Šต๋‹ˆ๋‹ค.

 

Traceback (most recent call last):
  File "/home/mingu/anaconda3/lib/python3.9/site-packages/airflow/providers/http/hooks/http.py", line 159, in check_response
    response.raise_for_status()
  File "/home/mingu/anaconda3/lib/python3.9/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.opensea.io/api/v1/assets?collection=doodles-official&limit=1    

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mingu/anaconda3/lib/python3.9/site-packages/airflow/sensors/base.py", line 277, in execute
    poke_return = self.poke(context)
  File "/home/mingu/anaconda3/lib/python3.9/site-packages/airflow/providers/http/sensors/http.py", line 135, in poke
    raise exc
  File "/home/mingu/anaconda3/lib/python3.9/site-packages/airflow/providers/http/sensors/http.py", line 122, in poke
    response = hook.run(
  File "/home/mingu/anaconda3/lib/python3.9/site-packages/airflow/providers/http/hooks/http.py", line 149, in run
    return self.run_and_check(session, prepped_request, extra_options)
  File "/home/mingu/anaconda3/lib/python3.9/site-packages/airflow/providers/http/hooks/http.py", line 202, in run_and_check
    self.check_response(response)
  File "/home/mingu/anaconda3/lib/python3.9/site-packages/airflow/providers/http/hooks/http.py", line 163, in check_response
    raise AirflowException(str(response.status_code) + ":" + response.reason)
airflow.exceptions.AirflowException: 403:Forbidden

 

์˜ค๋ฅ˜์˜ ํ‚ค์›Œ๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

1. 403 Client Error : Forbidden for url

2. airflow.exceptions.AirflowException : 403 : Forbidden

 

 

URL์€ ์ œ๋Œ€๋กœ ์ž…๋ ฅ๋˜์–ด ์žˆ์œผ๋ฉฐ, Airflow Connection๋„ ์ œ๋Œ€๋กœ ์ƒ์„ฑ๋œ ๊ฒƒ์„ ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ณด์•„ํ•˜๋‹ˆ, ์œ„ํ—˜ํ•˜๋‹ค๊ณ  ํŒ๋‹จํ•˜์—ฌ opensea ์„œ๋ฒ„์—์„œ ์ž์ฒด์ ์œผ๋กœ ์ฐจ๋‹จํ•œ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. opensea API ์ด์šฉ์„ ์œ„ํ•œ ์ธ์ฆ ํ˜น์€ ๊ถŒํ•œ์„ ๋ฐ›์•„์•ผ ํ•  ๊ฒƒ์œผ๋กœ ๋ณด์˜€๊ณ , ๊ทธ์— ํ•ด๋‹นํ•˜๋Š” api key๋ฅผ ๋ฐ›์•„์„œ ์ ‘๊ทผํ•˜์ž Success!


์—ฌ๋Ÿฌ๋ถ„๋„ ๋‹นํ™ฉํ•˜์ง€ ๋งˆ์‹œ๊ณ , ๋ฐ”๋กœ ํ•ด๋‹น ์‚ฌ์ดํŠธ๊ฐ€ ์–ด๋–ค ๊ถŒํ•œ/์ธ์ฆ์„ ์›ํ•˜๋Š”์ง€๋ถ€ํ„ฐ ์‚ดํŽด๋ณด์„ธ์š”!