Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
GoogleCodeExporter opened this issue Feb 6, 2016 · 3 comments
Closed

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

GoogleCodeExporter opened this issue Feb 6, 2016 · 3 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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

@GoogleCodeExporter
Copy link
Author

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

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

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

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant