prawn-cake / vk-requests

vk.com requests for humans. API library for vk.com
MIT License
158 stars 22 forks source link

User captcha handler #8

Closed clearsense closed 8 years ago

clearsense commented 8 years ago

Hi, what you think about do such thing?

Smth like this:

def require_auth_captcha(self, query_params, form_text, login_form_data,
                                       session, get_captcha_key=self.get_captcha_key):
...
    login_form_data['captcha_key'] = get_captcha_key(captcha_url) 

And same way add def do_login(self, session, get_captcha_key=None):

So, user could define own captcha handler. Or maybe this is wrong way and user must inherit AuthAPI class and redefine inherit() method?

clearsense commented 8 years ago

Sorry, this is already solved, as i see.

prawn-cake commented 8 years ago

For overriding those methods use your own subclass derived from AuthAPI and your custom vk session. So the composition looks like

class MyAuthAPI(AuthAPI):
    def do_login(self, ...):
        # implement whatever you want

    # other methods overridings

class MyVKSession(VKSession):
    DEFAULT_AUTH_API_CLS = MyAuthAPI

api = vk_requests.create_api(..., session_cls=MyVKSession)
clearsense commented 8 years ago

Yea, thanks a lot.