1

I tried this in both Java and Python and getting the same error. HTTPError: HTTP Error 405: Method Not Allowed

I'm trying to get access token by sending authentication code and client id. IN order to do this, I need to do a HTTP POST method.

https://developers.google.com/identity/protocols/OAuth2InstalledApp

import urllib
import urllib2   
url = 'https://accounts.google.com/o/oauth2/v3/token'
values = { 'code': '','client_id': '', 'client_secret':'', 'redirect_uri':'urn:ietf:wg:oauth:2.0:oob', 'grant_type':'', 'Content-Type':'application/x-www-form-urlencoded', 'Host':'www.googleapis.com' }

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
result = response.read()
print result
yome
  • 2,853
  • 5
  • 20
  • 18

0 Answers0