Reputation: 3929
I have a url:
https://www.facebook.com/dialog/oauth?client_id=559149457475028&redirect_uri=https://calm-refuge-2106.herokuapp.com/&scope=publish_stream
It redirects to another page with url:
https://calm-refuge-2106.herokuapp.com/?code=AQAoBPyS4lKynHM4lylFHChFyO775T-49A1j8DbTGO9iiyoKnkDv0naSWMSvJ26ISt50fTUGcYH8QfUdLwt4sLBQ9noNmBCuUsze4rVSjxCcJ1pbfcLpfy2OyLB5DMg7sOWr_q5dEHNEd9eXoeRepmjFDU7GyEUx6WrjDtIOcusH4prnPGhQ2gHopJC54AeflMC9bh6fP2R6OhAJhVCVMHNvIT2wwTB8DG46yoRP1GAqN-d2vm8RwOC93vY-Xv_HvGQKwhRxbpVlk2vWTMQ40F1rbaw_zJNz7oBtz7qDUQkxI3RcE6dWw5GEzPcFMFuD1jw#_=_
where I need to take only code query.
When I use urllib.urlopen to open the url and then geturl method to returned file-like object it returns something like this: https://www.facebook.com/login.php?skip_api_login=1&api_key=559149457475028&signed_next=1&next=https%3A%2F%2Fwww.facebook.com%2Fdialog%2Foauth%3Fredirect_uri%3Dhttps%253A%252F%252Fcalm-refuge-2106.herokuapp.com%252F%26scope%3Dpublish_stream%26client_id%3D559149457475028%26ret%3Dlogin&cancel_uri=https%3A%2F%2Fcalm-refuge-2106.herokuapp.com%2F%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied%23_%3D_&display=page
It's clearly not what i was looking for.
How can I get a url after redirecting in Python?
Upvotes: 1
Views: 410