Já entrei na máquina virtual e setei as variáveis de ambiente,.. mas persiste esse erro ao rodar:
$ python3 twitter_hook.py
[2022-06-06 18:01:41,251] {connection.py:344} ERROR - Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
Traceback (most recent call last):
File "/home/dcm/datapipeline/.env/lib/python3.9/site-packages/airflow/models/connection.py", line 342, in extra_dejson
obj = json.loads(self.extra)
File "/home/dcm/anaconda3/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/home/dcm/anaconda3/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/dcm/anaconda3/lib/python3.9/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
[2022-06-06 18:01:41,308] {connection.py:345} ERROR - Failed parsing the json for conn_id twitter_default
[2022-06-06 18:01:41,308] {base_hook.py:89} INFO - Using connection to: id: twitter_default. Host: https://api.twitter.com, Port: None, Schema: None, Login: None, Password: None, extra: None
[2022-06-06 18:01:41,310] {connection.py:344} ERROR - Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
Traceback (most recent call last):
File "/home/dcm/datapipeline/.env/lib/python3.9/site-packages/airflow/models/connection.py", line 342, in extra_dejson
obj = json.loads(self.extra)
File "/home/dcm/anaconda3/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/home/dcm/anaconda3/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/dcm/anaconda3/lib/python3.9/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
[2022-06-06 18:01:41,311] {connection.py:345} ERROR - Failed parsing the json for conn_id twitter_default
[2022-06-06 18:01:41,318] {twitter_hook.py:34} INFO - URL: https://api.twitter.com/2/tweets/search/recent?query=AluraOnline&tweet.fields=author_id,conversation_id,created_at,id,in_reply_to_user_id,public_metrics,text&expansions=author_id&user.fields=id,name,username,created_at
/home/dcm/datapipeline/.env/lib/python3.9/site-packages/urllib3/connectionpool.py:981: InsecureRequestWarning: Unverified HTTPS request is being made to host 'api.twitter.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
warnings.warn(
[2022-06-06 18:01:42,298] {http_hook.py:150} ERROR - HTTP error: Unauthorized
[2022-06-06 18:01:42,299] {http_hook.py:151} ERROR - {
"title": "Unauthorized",
"type": "about:blank",
"status": 401,
"detail": "Unauthorized"
}
Traceback (most recent call last):
File "/home/dcm/datapipeline/.env/lib/python3.9/site-packages/airflow/hooks/http_hook.py", line 148, in check_response
response.raise_for_status()
File "/home/dcm/datapipeline/.env/lib/python3.9/site-packages/requests/models.py", line 941, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.twitter.com/2/tweets/search/recent?query=AluraOnline&tweet.fields=author_id,conversation_id,created_at,id,in_reply_to_user_id,public_metrics,text&expansions=author_id&user.fields=id,name,username,created_at
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/dcm/datapipeline/airflow/plugins/hooks/twitter_hook.py", line 58, in <module>
for pg in TwitterHook("AluraOnline").run():
File "/home/dcm/datapipeline/airflow/plugins/hooks/twitter_hook.py", line 54, in run
yield from self.paginate(url, session)
File "/home/dcm/datapipeline/airflow/plugins/hooks/twitter_hook.py", line 43, in paginate
data = self.connect_to_endpoint(full_url, session)
File "/home/dcm/datapipeline/airflow/plugins/hooks/twitter_hook.py", line 35, in connect_to_endpoint
return self.run_and_check(session, prep, {}).json()
File "/home/dcm/datapipeline/.env/lib/python3.9/site-packages/airflow/hooks/http_hook.py", line 181, in run_and_check
self.check_response(response)
File "/home/dcm/datapipeline/.env/lib/python3.9/site-packages/airflow/hooks/http_hook.py", line 152, in check_response
raise AirflowException(str(response.status_code) + ":" + response.reason)
airflow.exceptions.AirflowException: 401:Unauthorized