Skip to content

Commit 17f11a0

Browse files
author
Hossein Amin
authored
specify urlencoded Content-Type (exchange_for_...)
In my situation Instagram was not able to read post content. And reason was content-type.
1 parent 6522cff commit 17f11a0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

instagram/oauth2.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def exchange_for_access_token(self, code=None, username=None, password=None, sco
109109
data = self._data_for_exchange(code, username, password, scope=scope, user_id=user_id)
110110
http_object = Http(disable_ssl_certificate_validation=True)
111111
url = self.api.access_token_url
112-
response, content = http_object.request(url, method="POST", body=data)
112+
headers={"Content-Type":"application/x-www-form-urlencoded"}
113+
response, content = http_object.request(url, method="POST", body=data, headers=headers)
113114
parsed_content = simplejson.loads(content.decode())
114115
if int(response['status']) != 200:
115116
raise OAuth2AuthExchangeError(parsed_content.get("error_message", ""))

0 commit comments

Comments
 (0)