Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4 from cwarden/url-decode-token

url-decode response parameters in RequestToken
  • Loading branch information...
commit dc8bec57ec62a8188fc8efc9fdeaacf965507e09 2 parents fc88a21 + 5a05d1f
@ignacio authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/OAuth.lua
View
12 src/OAuth.lua
@@ -2,14 +2,17 @@ local Base64 = require "base64"
local Crypto
local core
local isLuaNode
+local Url
if process then
Crypto = require "luanode.crypto"
core = require "OAuth.coreLuaNode"
+ Url = require "luanode.url"
isLuaNode = true
else
Crypto = require "crypto"
core = require "OAuth.coreLuaSocket"
+ Url = require "socket.url"
isLuaNode = false
end
@@ -248,7 +251,8 @@ function RequestToken(self, arguments, headers, callback)
local values = {}
for key, value in string.gmatch(response_body, "([^&=]+)=([^&=]*)&?" ) do
--print( ("key=%s, value=%s"):format(key, value) )
- values[key] = value
+ -- The response parameters are url-encodeded per RFC 5849 so we need to decode them
+ values[key] = Url.unescape(value)
end
self.m_oauth_token_secret = values.oauth_token_secret
@@ -269,7 +273,7 @@ function RequestToken(self, arguments, headers, callback)
local values = {}
for key, value in string.gmatch(response_body, "([^&=]+)=([^&=]*)&?" ) do
--print( ("key=%s, value=%s"):format(key, value) )
- values[key] = value
+ values[key] = Url.unescape(value)
end
oauth_instance.m_oauth_token_secret = values.oauth_token_secret
@@ -401,7 +405,7 @@ function GetAccessToken(self, arguments, headers, callback)
local values = {}
for key, value in string.gmatch(response_body, "([^&=]+)=([^&=]*)&?" ) do
--print( ("key=%s, value=%s"):format(key, value) )
- values[key] = value
+ values[key] = Url.unescape(value)
end
self.m_oauth_token_secret = values.oauth_token_secret
self.m_oauth_token = values.oauth_token
@@ -422,7 +426,7 @@ function GetAccessToken(self, arguments, headers, callback)
local values = {}
for key, value in string.gmatch(response_body, "([^&=]+)=([^&=]*)&?" ) do
--print( ("key=%s, value=%s"):format(key, value) )
- values[key] = value
+ values[key] = Url.unescape(value)
end
oauth_instance.m_oauth_token_secret = values.oauth_token_secret
Please sign in to comment.
Something went wrong with that request. Please try again.