Skip to content

Commit

Permalink
fixes in handling errorcode 17
Browse files Browse the repository at this point in the history
  • Loading branch information
ramusus committed Jan 13, 2015
1 parent e64cc5d commit 44aade3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
'django',
'django-annoying',
'django-picklefield',
'django-oauth-tokens>=0.4.7',
'django-oauth-tokens>=0.4.9',
'vkontakte',
'simplejson',
'beautifulsoup4',
Expand Down
12 changes: 10 additions & 2 deletions vkontakte_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,18 @@ def handle_error_code_10(self, e, *args, **kwargs):
def handle_error_code_17(self, e, *args, **kwargs):
# Validation required: please open redirect_uri in browser
# TODO: cover with tests
auth_request = AccessToken.objects.get_token('vkontakte').auth_request
self.logger.warning("Request error: %s. Error registered while executing \
method %s with params %s, recursion count: %d" % (e, self.method, kwargs, self.recursion_count))

user = AccessToken.objects.get(access_token=self.api.token).user_credentials
auth_request = AccessToken.objects.get_token_for_user('vkontakte', user).auth_request
auth_request.form_action_domain = 'https://m.vk.com'

response = auth_request.session.get(e.redirect_uri)
method, action, data = auth_request.get_form_data_from_content(response.content)
try:
method, action, data = auth_request.get_form_data_from_content(response.content)
except:
raise Exception("There is no any form in response: %s" % response.content)
data = {'code': auth_request.additional}
response = getattr(auth_request.session, method)(url=action, headers=auth_request.headers, data=data)

Expand Down

0 comments on commit 44aade3

Please sign in to comment.