Skip to content

Commit

Permalink
request body with bytes data.
Browse files Browse the repository at this point in the history
related issue: lepture#65
  • Loading branch information
lepture committed Dec 20, 2013
1 parent c31ff03 commit 48085c9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions flask_oauthlib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from flask import request, redirect, json, session, current_app
from werkzeug import url_quote, url_decode, url_encode
from werkzeug import parse_options_header, cached_property
from .utils import to_bytes
try:
from urlparse import urljoin
import urllib2 as http
Expand Down Expand Up @@ -433,7 +434,7 @@ def request(self, url, data=None, headers=None, format='urlencoded',
uri, headers, body = self.pre_request(uri, headers, body)

resp, content = self.http_request(
uri, headers, data=body, method=method
uri, headers, data=to_bytes(body, self.encoding), method=method
)
return OAuthResponse(resp, content, self.content_type)

Expand Down Expand Up @@ -550,7 +551,9 @@ def handle_oauth1_response(self):
_encode(self.access_token_method)
)

resp, content = self.http_request(uri, headers, data)
resp, content = self.http_request(
uri, headers, to_bytes(data, self.encoding)
)
data = parse_response(resp, content)
if resp.code not in (200, 201):
raise OAuthException(
Expand All @@ -574,7 +577,7 @@ def handle_oauth2_response(self):
body = client.prepare_request_body(**remote_args)
resp, content = self.http_request(
self.expand_url(self.access_token_url),
data=body,
data=to_bytes(body, self.encoding),
method=self.access_token_method,
)
elif self.access_token_method == 'GET':
Expand Down

0 comments on commit 48085c9

Please sign in to comment.