I am trying to get a token from the Google OAuth api. I have already successfully been able to get the temporary auth code.
However, my requests are returning a 404 error, with the normal Google "That's an error" 404 page. Here is my Python code:
data = { "code":auth_code, "client_id":client_id, "client_secret":client_secret, "redirect_uri":redirect_uri, "grant_type":"authorization_code" } headers = {"Content-Type":"application/x-www-form-urlencoded"} r = requests.post("https://googleapis.com/oauth/v4/token",data=data,headers=headers) I get the same error no matter if I url-encode my parameters or not (I think the requests library does it anyway).
Here are the data I am sending in more detail (censored of course)
'client_id':'2-------------------------------------------0.apps.googleusercontent.com', 'client_secret': '5----------------------p', 'code': '4/A-------------------------- ... ------------------------------------fGE#', 'grant_type': 'authorization_code', 'redirect_uri': 'https://localhost' I understand the question here is very similar to mine but all the solutions provided either don't work (url encoding) or don't apply (everything else).
I am using this official documentation for reference.
This is probably very obvious, like most of the questions I ask here.
Edit - I tried
data = "code="+auth_code+"&client_id="+client_id+"&client_secret="+client_secret+"&redirect_uri="+redirect_uri+"&grant_type=authorization_code" ...which returned a 400. With or without url-encoding.