edisona / oauth

Automatically exported from code.google.com/p/oauth
1 stars 0 forks source link

python: client should set content-type for post #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The SimpleOAuthClient example's access_resource() function uses POST, but
does not set the content-type. Some web servers (e.g. Tomcat) will not
identify that the content contains HTTP parameters unless the content-type
is set properly.

Something like this works for me:
    def access_resource(self, oauth_request):
        # via post body
        # -> some protected resources
        headers = { 'Content-Type' :'application/x-www-form-urlencoded' }
        self.connection.request('POST', RESOURCE_URL,
body=oauth_request.to_postdata(), headers=headers)
        response = self.connection.getresponse()
        return response.read()

Original issue reported on code.google.com by jesse.my...@gmail.com on 27 Mar 2008 at 7:20

GoogleCodeExporter commented 9 years ago

Original comment by leah.culver on 7 Jul 2008 at 11:15

GoogleCodeExporter commented 9 years ago

Original comment by leah.culver on 7 Jul 2008 at 11:16

GoogleCodeExporter commented 9 years ago
SimpleOAuthClient was really only meant to work with the test server :D

However, I've made the change since it makes sense. Thanks!

Original comment by leah.culver on 8 Jul 2008 at 4:56