problem with python request.get when trying to get instagramm access code
I've got a problem when trying to construct url with request.get() method to handle instagramm oauth
that's what I'm doing:
def get_code(uri, id):
params = {
'client_id': id
,'redirect_uri': uri
,'scope': 'user_profile,user_media'
,'response_type': 'code'
}
r = requests.get('https://www.instagram.com/oauth/authorize/'
,params = params)
input(r.url)
and when evoking function with such parameters
get_code('https://6b4c-46-39-51-57.ngrok.io/autos/', 96597520768760)
I'm expecting such url when printing r.url:
https://www.instagram.com/oauth/authorize?client_id=965975207687609&redirect_uri=https://6b4c-46-39-51-57.ngrok.io/autos/&scope=user_profile,user_media&response_type=code
but loock what I'm getting instead:
https://www.instagram.com/accounts/login/?force_authentication=1&enable_fb_login=1&next=/oauth/authorize/%3Fclient_id%3D96597520768760%26redirect_uri%3Dhttps%3A//6b4c-46-39-51-57.ngrok.io/autos/%26scope%3Duser_profile%2Cuser_media%26response_type%3Dcode
does sombody have a clue why request.get().ull returns me not the url I was trying to construct?
Solution 1:
try to access the first link on your browser's private mode, you would notice that you will be redirected to the second link, as you are not logged in, and dont have access to the ressources asked.
so requests, is really sending a get request to the first link, but the request gets redirected to the second link.