jvmachadorj / instagram-telegram-bot

10 stars 5 forks source link

401 "Unauthorized" Error #9

Closed drdoof2019 closed 3 years ago

drdoof2019 commented 4 years ago

Hello, when I run the program it gives:

Fail to import moviepy. Need only for Video upload.
Request return 405 error!
{'message': '', 'status': 'fail'}
Request return 404 error!
Login success!

Listening ...
Traceback (most recent call last):
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/loop.py", line 31, in run_forever
    allowed_updates=allowed_updates)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/__init__.py", line 587, in getUpdates
    return await self._api_request('getUpdates', _rectify(p))
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/__init__.py", line 78, in _api_request
    return await api.request((self._token, method, params, files), **kwargs)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/api.py", line 146, in request
    return await _parse(r)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/api.py", line 129, in _parse
    raise e(description, error_code, data)
telepot.exception.UnauthorizedError: ('Unauthorized', 401, {'ok': False, 'error_code': 401, 'description': 'Unauthorized'})
Traceback (most recent call last):
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/loop.py", line 31, in run_forever
    allowed_updates=allowed_updates)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/__init__.py", line 587, in getUpdates
    return await self._api_request('getUpdates', _rectify(p))
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/__init__.py", line 78, in _api_request
    return await api.request((self._token, method, params, files), **kwargs)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/api.py", line 146, in request
    return await _parse(r)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/api.py", line 129, in _parse
    raise e(description, error_code, data)
telepot.exception.UnauthorizedError: ('Unauthorized', 401, {'ok': False, 'error_code': 401, 'description': 'Unauthorized'})

by the way example env file contains:

TAGS_ID = 'rekite client id'

but I don't know what is that. is it my problem?

drdoof2019 commented 4 years ago

I changed my telegram api code I think that was the problem. Now, program says Listening... and keeps waiting.

Fail to import moviepy. Need only for Video upload.
Request return 429 error!
{'message': 'Please wait a few minutes before you try again.', 'status': 'fail'}
Request return 405 error!
{'message': '', 'status': 'fail'}
Request return 404 error!
Login success!

Listening ...

waited for 10 min and nothing happened

edit : it turns out the program waited for me to write /start to my bot. after started my bot in telegram this error occured;

Listening ...
https://pixabay.com/get/53e5d2414a57ad14f6da8c7dda7936761d39d9e355596c48732f78d3924bc559bc_1280.jpg
19
Traceback (most recent call last):
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/delegate.py", line 88, in wait_loop
    await helper._invoke(j.on_message, msg)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/helper.py", line 16, in _invoke
    return await fn(*args, **kwargs)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/helper.py", line 191, in augmented
    return await _invoke(handler, msg)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/helper.py", line 16, in _invoke
    return await fn(*args, **kwargs)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/helper.py", line 269, in on_message
    await self._router.route(msg)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/helper.py", line 244, in route
    return await _invoke(fn, msg, *args, **kwargs)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/helper.py", line 16, in _invoke
    return await fn(*args, **kwargs)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/helper.py", line 24, in d
    return await _invoke(method, *a, **kw)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/telepot/aio/helper.py", line 16, in _invoke
    return await fn(*args, **kwargs)
  File "telegram_bot.py", line 81, in on_chat_message
    await self._propose()
  File "telegram_bot.py", line 71, in _propose
    image = download_photo()
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/upload_photos.py", line 77, in download_photo
    image = save_to_db(result, path, url)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/upload_photos.py", line 156, in save_to_db
    caption = create_random_caption(tags)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/upload_photos.py", line 140, in create_random_caption
    treated_tags = treat_tags(tags)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/upload_photos.py", line 119, in treat_tags
    format(tag, config('TAGS_ID'))
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/decouple.py", line 197, in __call__
    return self.config(*args, **kwargs)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/decouple.py", line 85, in __call__
    return self.get(*args, **kwargs)
  File "/home/sule/Masaüstü/igtelbottry/instagram-telegram-bot/venv/lib/python3.6/site-packages/decouple.py", line 70, in get
    raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
decouple.UndefinedValueError: TAGS_ID not found. Declare it as envvar or define a default value.

what is TAGS_ID = 'rekite client id'?

jvmachadorj commented 3 years ago

Hello @drdoof2019

There is a mispelling word right there, It is RiteKit Client ID you can find it here https://ritekit.com/developer/dashboard/

I've updated de Readme file to add where to get this credentials.

RiteKit is an open api to generate hashtags based on some text. So that's why it is a project dependecy. I've also refactored the code so it is a bit more clear and exclude some unused code.

My next steps are to make this bot scalable and do a package for it. If you have any questions please don't hesitate to contact me

jvmachadorj commented 3 years ago

@drdoof2019 Actually I was looking in the documents for the main package I was using and actually it is not supported anymore