Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files
The oauth_request module shouldn't need to know about the HMAC-SHA1 b…
…ase string.
  • Loading branch information
Tim Fletcher committed Aug 24, 2008
1 parent eb83677 commit e867f1e005784a6c40057f09a20b914c8081e6b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
@@ -1,15 +1,19 @@


% for testing:
-export([normalize/1]). % for testing

signature({Method, URL, Params}, ConsumerSecret, TokenSecret) ->
signature(base_string(Method, URL, Params), ConsumerSecret, TokenSecret);
signature(BaseString, ConsumerSecret, TokenSecret) ->
b64(crypto:sha_mac(key(ConsumerSecret, TokenSecret), BaseString)).

base_string(MethodString, URL, Params) ->
string:join(lists:map(fun fmt:percent_encode/1, [MethodString, URL, normalize(Params)]), "&").
base_string(Method, URL, Params) when is_list(Method) ->
string:join(lists:map(fun fmt:percent_encode/1, [Method, URL, normalize(Params)]), "&").

normalize(Params) ->
@@ -51,8 +51,7 @@ signature(Method, URL, Params, Consumer, TokenSecret) ->
oauth_plaintext:signature(ConsumerSecret, TokenSecret);
"HMAC-SHA1" ->
BaseString = oauth_hmac:base_string(string:to_upper(atom_to_list(Method)), URL, Params),
oauth_hmac:signature(BaseString, ConsumerSecret, TokenSecret)
oauth_hmac:signature({string:to_upper(atom_to_list(Method)), URL, Params}, ConsumerSecret, TokenSecret)

signature_method(Params) ->

0 comments on commit e867f1e

Please sign in to comment.