README.txt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ============
  2. erlang-oauth
  3. ============
  4. What is this?
  5. -------------
  6. An Erlang wrapper around the OAuth protocol.
  7. What is OAuth?
  8. --------------
  9. An "open protocol to allow secure API authentication in a simple and standard
  10. method from desktop and web applications". See http://oauth.net/ for more info.
  11. What do I need?
  12. ---------------
  13. Erlang, and erlang-fmt (http://tfletcher.com/dev/erlang-fmt).
  14. The Makefile assumes that erlang-fmt is contained in the parent directory of
  15. this one, so you might want to edit the Makefile if you have it elsewhere.
  16. Erlang R12B-5 is required for RSA-SHA1 signing.
  17. How do I use it?
  18. ----------------
  19. First, create a consumer:
  20. Consumer = oauth_consumer:new("key", "secret", SignatureMethod).
  21. SignatureMethod can either be "PLAINTEXT", "HMAC-SHA1", or {"RSA-SHA1", PK},
  22. where PK is either a path pointing to a private key PEM file, or a tuple as
  23. returned by public_key:decode_private_key/1.
  24. Requests can be made with oauth:get and oauth:post, e.g.,
  25. Response = oauth:get(URL, Consumer).
  26. URL must not contain a query string. Instead, pass the query parameters in
  27. as an additional [proplist] argument, e.g.,
  28. Response = oauth:get(URL, Consumer, [{foo, "bar"}]).
  29. Calling oauth:get or oauth:post returns an HTTP response tuple, as would
  30. be returned from http:request/4. If you are requesting tokens you can use
  31. oauth_token_pair:new/1 to extract the oauth_token and oauth_token_secret
  32. parameters from the response, e.g.,
  33. TokenPair={Token, TokenSecret} = oauth_token_pair:new(Response).
  34. TokenPair can then be passed back into oauth:get and oauth:post to
  35. request additional tokens, or a protected resource. Alternatively, you
  36. can use oauth_request:to_header/2,4 to generate an HTTP Authorization
  37. header, as described by http://oauth.net/core/1.0/#auth_header. This
  38. isn't (currently) integrated into oauth:get and oauth:post, so you
  39. would need to use http:request/4 directly in this case.
  40. Are there any examples anywhere?
  41. --------------------------------
  42. Yes. See test/oauth_termie.erl and test/oauth_google.erl. They can be
  43. run with "make termie_hmac", "make termie_rsa", and "make google".
  44. Who can I contact if I have another question?
  45. ---------------------------------------------
  46. Tim Fletcher (http://tfletcher.com/).