-
Notifications
You must be signed in to change notification settings - Fork 325
Fix cookie login #491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cookie login #491
Conversation
- Support captcha on twofactor path - Fix sid verification - Fix OAuth response parsing
| response = self.http.get(url) | ||
| elif 'redirect_uri' in response.url: | ||
| response = self.http.get(response.url) | ||
| auth_json = json.loads(search_re(RE_AUTH_TOKEN_URL, response.text)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, on the first run it failed to parse it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response status code is 429 Too Many Requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe need to add a delay between requests?
| } | ||
| ) | ||
|
|
||
| self.token = response.json()['response'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And once failed with 🤔
{"error":{"error_code":5,"error_msg":"User authorization failed: access_token was given to another ip address","error_text":"Failed to connect to network. Please close the page and try again.",
|
|
||
| response = self.http.get('https://vk.com/feed2.php').json() | ||
| feed_url = 'https://vk.com/feed.php' | ||
| response = self.http.get(feed_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sometimes goes trough some redirects
0.49 GET https://vk.com/feed.php ... None 302 []
0.47 GET https://login.vk.com/?role=fast&_origin= ... None 302 []
0.18 GET https://vk.com/login.php?slogin_h= ... None 302 []
0.15 GET https://vk.com/feed.php ... None 200 []
|
And security check: It would be good to look into making it more reliable and check if possible to avoid all the redirects |
Woke up this morning and tried to log in.
Everything worked fine at the beginning, however it was constanly asking me for two-factor code. Well, I didn't care, but after a while the
statusvariable started to receive code 2, which indicated that I had to type in captcha code, I was getting the Recaptcha exception, so I had to fix this somehow. Someone suggested that using token-only auth should fix the issue, but later I needed to use an API that is only present in web version, so I needed a cookie login to get working.Using this wonderful repo I figured out what the fields in the response mean, added a captcha call in the code, and it started to pass after that.
However it wasn't enough. Although the remixsid was valid, I wasn't able to get the access_token in the _api_login function. I was getting a weird redirect to a webpage that had "grant" button. So with the help of Firefox's network logger I was able to reconstruct the algorithm, but it was painful to implement it in Python because
connect_internalmethod was giving me awrong_hosterror. After hours of checking for mistakes in the traffic I figured out that it looks atOrigin:header value - setting it explicitly toid.vk.comfixed the issue and I was finally able to log in!The only issue left is
check_sidfunction. It turns out thatfeed2.phpis completely broken now - it always gives you ID of -1 even though you logged in in the browser.feed.phpworks fine though - it redirects you to login page if you have incorrect credentials.