bellingcat / vk-url-scraper

Scrape VK URLs to fetch info and media - python API or command line tool.
https://pypi.org/project/vk-url-scraper/
MIT License
38 stars 6 forks source link

Unknown API auth error #62

Open iknoorjobs opened 2 months ago

iknoorjobs commented 2 months ago

🐛 Describe the bug

Hi, When I run the following code with my credentials, it gives an error "AuthError: Unknown API auth error", could you please tell me what might be causing the issue?

from vk_url_scraper import VkScraper
vks = VkScraper("username", "password")
# scrape any "video" URL
res = vks.scrape("https://vk.com/video-6596301_145810025")

Error:

---------------------------------------------------------------------------
AuthError                                 Traceback (most recent call last)
<ipython-input-87-3f4ee1c1cb0d> in <module>
      1 from vk_url_scraper import VkScraper
      2 
----> 3 vks = VkScraper("+44□□□□□□□□□□", "Qa□□□□□□□□")
      4 
      5 # scrape any "video" URL

~/miniconda3/lib/python3.8/site-packages/vk_url_scraper/scraper.py in __init__(self, username, password, token, session_file, captcha_handler)
     74         )
     75         if token is None or len(token) == 0:
---> 76             self.session.auth(token_only=True)
     77 
     78     def scrape(self, url: str) -> List:

~/miniconda3/lib/python3.8/site-packages/vk_api/vk_api.py in auth(self, reauth, token_only)
    183 
    184         if token_only:
--> 185             self._auth_token(reauth=reauth)
    186         else:
    187             self._auth_cookies(reauth=reauth)

~/miniconda3/lib/python3.8/site-packages/vk_api/vk_api.py in _auth_token(self, reauth)
    235         elif self.password:
    236             self._vk_login()
--> 237             self._api_login()
    238 
    239     def _vk_login(self, captcha_sid=None, captcha_key=None):

~/miniconda3/lib/python3.8/site-packages/vk_api/vk_api.py in _api_login(self)
    514 
    515         else:
--> 516             raise AuthError('Unknown API auth error')
    517 
    518     def server_auth(self):

AuthError: Unknown API auth error

Versions

Python 3.8.5 vk==3.0 vk-api==11.9.9 vk-url-scraper==0.3.27

GalenReich commented 2 months ago

Hi Iknoor, thanks for opening this issue. This bug appears to be related to an upstream issue that we are tracking at the moment, namely: https://github.com/python273/vk_api/issues/496

@msramalho has a live issue on the vk_api repo https://github.com/python273/vk_api/issues/500 to try and get code to fix this merged to the upstream repository, and he may be able to help further.

msramalho commented 2 months ago

Yeah, it's a bummer. You can still get this tool to run if you install it locally and then install vk_api directly from their GitHub.

Another option is in this answer: https://github.com/python273/vk_api/issues/496#issuecomment-1959996394 which requires you finding the client_secret that you can probably intercept from a web browser after logging in and digging around the Network panel for request parameters or cookies.