README.txt 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. An Erlang OAuth implementation.
  2. Quick start (client usage):
  3. $ make
  4. ...
  5. $ erl -pa ebin -s crypto -s inets
  6. ...
  7. 1> Consumer = {"key", "secret", hmac_sha1}.
  8. ...
  9. 2> RequestTokenURL = "http://term.ie/oauth/example/request_token.php".
  10. ...
  11. 3> {ok, RequestTokenResponse} = oauth:get(RequestTokenURL, [], Consumer).
  12. ...
  13. 4> RequestTokenParams = oauth:params_decode(RequestTokenResponse).
  14. ...
  15. 5> RequestToken = oauth:token(RequestTokenParams).
  16. ...
  17. 6> RequestTokenSecret = oauth:token_secret(RequestTokenParams).
  18. ...
  19. 7> AccessTokenURL = "http://term.ie/oauth/example/access_token.php".
  20. ...
  21. 8> {ok, AccessTokenResponse} = oauth:get(AccessTokenURL, [], Consumer, RequestToken, RequestTokenSecret).
  22. ...
  23. 9> AccessTokenParams = oauth:params_decode(AccessTokenResponse).
  24. ...
  25. 10> AccessToken = oauth:token(AccessTokenParams).
  26. ...
  27. 11> AccessTokenSecret = oauth:token_secret(AccessTokenParams).
  28. ...
  29. 12> URL = "http://term.ie/oauth/example/echo_api.php".
  30. ...
  31. 13> {ok, Response} = oauth:get(URL, [{"hello", "world"}], Consumer, AccessToken, AccessTokenSecret).
  32. ...
  33. 14> oauth:params_decode(Response).
  34. ...
  35. Consumer credentials are represented as follows:
  36. {Key::string(), Secret::string(), plaintext}
  37. {Key::string(), Secret::string(), hmac_sha1}
  38. {Key::string(), RSAPrivateKeyPath::string(), rsa_sha1} % client side
  39. {Key::string(), RSACertificatePath::string(), rsa_sha1} % server side
  40. The percent encoding/decoding implementations are based on those found in
  41. the ibrowse library, written by Chandrashekhar Mullaparthi.
  42. Example client/server code is at http://github.com/tim/erlang-oauth-examples.
  43. Unit tests are at http://github.com/tim/erlang-oauth-tests.
  44. Erlang/OTP R14B or greater is required for RSA-SHA1.