A
A
Alex F2019-06-06 15:23:00
Python
Alex F, 2019-06-06 15:23:00

How to catch VK API redirect?

Welcome all!
Dear, how can I get an answer from

http://oauth.vk.com/authorize?client_id=ИД-ПРИЛОЖЕНИЯ&redirect_uri=https://oauth.vk.com/blank.html&scope=audio,video,notes,pages,status,offers,questions,wall,groups,email,notifications,stats,ads,offline,docs,friends&response_type=token

as
https://oauth.vk.com/blank.html#access_token=ОЧЕНЬ-МНОГО-СИМВОЛОВ&expires_in=0&user_id=ИД-ПОЛЬЗОВАТЕЛЯ&[email protected]

None of this ⬇ helps, but works in the browser
example
headers = {
    'User-Agent': ('Mozilla/5.0 (Windows NT 6.0; rv:14.0) Gecko/20100101 '
                   'Firefox/14.0.1'),
    'Accept':
    'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'Accept-Language':
    'ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3',
    'Accept-Encoding':
    'gzip, deflate',
    'Connection':
    'keep-alive',
    'DNT':
    '1'
}
uri = 'http://oauth.vk.com/authorize?client_id=ИД-ПРИЛОЖЕНИЯ&redirect_uri=https://oauth.vk.com/blank.html&scope=audio,video,notes,pages,status,offers,questions,wall,groups,email,notifications,stats,ads,offline,docs,friends&response_type=token'
response = requests.post(uri, headers=headers, allow_redirects=True)
print (response.status_code)
if response.history:
    print ("Request was redirected")
    for resp in response.history:
        print (resp.status_code, resp.url)
    print ("Final destination:")
    print (response.status_code, response.url)
else:
    print ("Request was not redirected")
res = urllib.request.urlopen(uri)
finalurl = res.geturl()
print (finalurl)
print ('\n', response.url)


They didn’t ban me in Google, I know English, I read https://docs.python.org/3.6/library/urllib.request.html .
Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question