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!
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
Post a Comment