kulpa / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

Facebook Responds with String, Not JSON #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
File: google-api-python-client/oauth2client/client.py

To make OAuth2WebServerFlow(Flow) work with Facebook, in step2_exchange(), 
change:

# TODO(jcgregorio) Raise an error if simplejson.loads fails?
d = simplejson.loads(content)

...to...

# TODO(jcgregorio) Raise an error if simplejson.loads fails?
try:
    d = simplejson.loads(content)
except:
    d = response_decoder(content)

...and add this response_decoder() function:

def response_decoder(body):
    params = {}
    for k, v in urlparse.parse_qs(body).iteritems():
        if len(v) > 1:
            params[k] = v
        else:
            params[k] = v[0]
    return params

Original issue reported on code.google.com by james.thornton on 12 Jun 2011 at 1:15

GoogleCodeExporter commented 9 years ago
It would be great if you could follow the steps here and submit a patch for 
that:  
http://code.google.com/p/google-api-python-client/wiki/BecomingAContributor

Original comment by jcgregorio@google.com on 12 Jun 2011 at 5:54

GoogleCodeExporter commented 9 years ago

Original comment by jcgregorio@google.com on 29 Jun 2011 at 4:05

GoogleCodeExporter commented 9 years ago
If someone wants to contribute a patch I will accept it.

Original comment by jcgregorio@google.com on 9 Nov 2011 at 7:06