[Snowy] [PATCH] Make sure that the OAuth responses are sent back with the correct content-type.



I was running into issues where the OAuth responses were being received
by Tomboy with HTML tags, for example:

<html><head/><body><p>oauth_token_secret=46pD5dugFL3EqBYXVAJbpuLWyL4TuyVK&amp;oauth_token=cMjC4YXgFFNKZfpHUK&amp;oauth_callback_confirmed=true</p></body></html>

After a lot of digging it turned out that the content-type is
text/html. According to RFC5849 the correct content-type for OAuth
responses is application/x-www-form-urlencoded .  Changing it to this
has resolved my issue. ---  lib/piston/authentication.py |    4 ++--  1
files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/piston/authentication.py b/lib/piston/authentication.py
index 63bec85..8512f0f 100644
--- a/lib/piston/authentication.py
+++ b/lib/piston/authentication.py
@@ -162,7 +162,7 @@ def oauth_request_token(request):
     try:
         token = oauth_server.fetch_request_token(oauth_request)
 
-        response = HttpResponse(token.to_string())
+        response = HttpResponse(token.to_string(),
content_type="application/x-www-form-urlencoded")
     except oauth.OAuthError, err:
         response = send_oauth_error(err)
 
@@ -234,7 +234,7 @@ def oauth_access_token(request):
         
     try:
         token = oauth_server.fetch_access_token(oauth_request)
-        return HttpResponse(token.to_string())
+        return HttpResponse(token.to_string(),
content_type="application/x-www-form-urlencoded")
     except oauth.OAuthError, err:
         return send_oauth_error(err)
 
-- 
1.7.2.3


Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]