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!
์ฌ๋ฌ๋ถ๋ ๋นํฉํ์ง ๋ง์๊ณ , ๋ฐ๋ก ํด๋น ์ฌ์ดํธ๊ฐ ์ด๋ค ๊ถํ/์ธ์ฆ์ ์ํ๋์ง๋ถํฐ ์ดํด๋ณด์ธ์!
'๐ Data Engineering > Apache Airflow' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Airflow] Airflow & Spark ์ฐ๋ํด์ ํ์ฉํ๊ธฐ (2) (2) | 2022.09.19 |
---|---|
[Airflow] Airflow & Spark ์ฐ๋ํด์ ํ์ฉํ๊ธฐ (1) (0) | 2022.09.17 |
[Airflow] Airflow ๊ธฐ์ด ์ง์ (0) | 2022.09.15 |