Browse Source

turn atoms into strings before sorting, since erlang sorts atoms before strings

Paul Bonser 16 years ago
parent
commit
0ac0d564f3
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/oauth_hmac.erl

+ 3 - 2
src/oauth_hmac.erl

@@ -16,7 +16,8 @@ base_string(Method, URL, Params) when is_list(Method) ->
   string:join(lists:map(fun fmt:percent_encode/1, [Method, uri_normalize(URL), normalize(Params)]), "&").
 
 normalize(Params) ->
-  oauth_params:to_string(sort(Params)).
+  StringParams = lists:map(fun({K, V}) when is_atom(K) -> {atom_to_list(K), V}; (I) -> I end, Params),
+  oauth_params:to_string(sort(StringParams)).
 
 uri_normalize(URL) ->
   case http_uri:parse(URL) of
@@ -33,4 +34,4 @@ key(ConsumerSecret, TokenSecret) ->
   fmt:sprintf("%s&%s", [fmt:percent_encode(ConsumerSecret), fmt:percent_encode(TokenSecret)]).
 
 b64(Data) ->
-  base64:encode_to_string(Data).
+  base64:encode_to_string(Data).