api - Why do my browsers redirect me with this URL, but Python doesn't? -


when use urllib, urllib2, or requests on python 2.7, neither 1 ends @ same url when copy , paste starting url chrome or firefox mac.

edit: suspect because 1 has signed in vk.com redirected. if case, how add sign-in script? thanks!

starting url: https://oauth.vk.com/authorize?client_id=private&redirect_uri=https://oauth.vk.com/blank.html&scope=friends&response_type=token&v=5.68

actual final (redirected) url: https://oauth.vk.com/blank.html#access_token=private_token&expires_in=86400&user_id=private

private, private_token = censored information

the following 1 of several attempts @ this:

import requests  appid = 'private' display_option = 'popup' # or 'window' or 'mobile' or 'popup' redirect_url = 'https://oauth.vk.com/blank.html' scope = 'friends' # https://vk.com/dev/permissions response_type = 'token' # documentation vague on this. don't know          # other options there are, given context, i.e. want         # "access token", suppose correct input  url = 'https://oauth.vk.com/authorize?client_id=' + appid + \       '&display='+ display_option + \       '&redirect_uri=' + redirect_url + \       '&scope=' + scope + \       '&response_type=' + response_type + \       '&v=5.68'  # requests  request = requests.get(url)  response_url = request.url 

i hope notice whatever that's wrong code.

extra info: need redirect because private_token value necessary further programming.

i tried debugging neither interpreter nor ipython print out debugging info.

thanks!

the problem result of not being signed in in python environment.

solution:

use twill create browser in python , sign in.

code:

from twill.commands import *  browser = get_browser()  browser.go(url) # url url concatenated in question  response_url = browser.get_url() 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -