It's really just that you are sending 'Content-type'
in the body when it should be sent in headers. Additionally, you don't need 'POST': '/o/oauth2/token HTTP/1.1'
and 'HOST:': 'accounts.google.com'
in your body. Try doing this:
h = Http()
post_data = {'client_id':ClientID,
'client_secret':ClientSecret,
'refresh_token':SavedRefreshToken,
'grant_type':'refresh_token'}
headers = {'Content-type': 'application/x-www-form-urlencoded'}
resp, content = h.request("https://accounts.google.com/o/oauth2/token",
"POST",
urlencode(post_data),
headers=headers)
print content
It should print something like:
{
"access_token" : "ya29.AHBS6ZCtS8mBc_vEC9FFBkW2x3ipa7FLOs-Hi-3UhVkpacOm",
"token_type" : "Bearer",
"expires_in" : 3600
}