I am trying to get a new access token by using a refresh token as described by Google here. Google says I need to make a HTTP request. I had no clue how to do that, so I looked up how to do it from here. However, I must be doing the post incorrectly because I get an invalid_request
error.
Below is my relevant code:
h = Http()
post_data = {'POST': '/o/oauth2/token HTTP/1.1',
'HOST:': 'accounts.google.com',
'Content-Type:': 'application/x-www-form-urlencoded',
'client_id':ClientID,
'client_secret':ClientSecret,
'refresh_token':SavedRefreshToken,
'grant_type':'refresh_token'}
resp, content = h.request("https://accounts.google.com/o/oauth2/token",
"POST",
urlencode(post_data))
And the response I get is:
{
"error" : "invalid_request"
}
What am I missing here?