README.txt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. How do I use it?
  17. ----------------
  18. The crypto and inets applications need to be running, and---as it's easy to
  19. forget---all the code needs to be compiled. A typical authentication flow
  20. would be similar to the following:
  21. ConsumerKey = "key",
  22. ConsumerSecret = "secret",
  23. SignatureMethod = "HMAC-SHA1",
  24. Consumer = oauth_consumer:new(ConsumerKey, ConsumerSecret, SignatureMethod),
  25. HttpResponse = oauth:get(RequestTokenURL, Consumer),
  26. RequestTokenPair = oauth_token_pair:new(HttpResponse),
  27. % If necessary, direct user to the Service Provider,
  28. % with RequestToken = element(1, RequestTokenPair).
  29. HttpResponse2 = oauth:get(AccessTokenURL, Consumer, RequestTokenPair),
  30. AccessTokenPair = oauth_token_pair:new(HttpResponse2),
  31. oauth:get(ProtectedResourceURL, Consumer, AccessTokenPair, ExtraParams).
  32. Calling oauth:get or oauth:post returns an HTTP response tuple, as returned
  33. from http:request/4. Type "make termie", or look at the oauth_termie module
  34. for a working example. Thanks Andy!
  35. Alternatively, you can use oauth_request:header/6 to generate an HTTP
  36. Authorization header, as described by http://oauth.net/core/1.0/#auth_header.
  37. This isn't (currently) integrated into oauth:get and oauth:post, so you would
  38. need to use http:request/4 directly in this case.
  39. Who can I contact if I have another question?
  40. ---------------------------------------------
  41. Tim Fletcher (http://tfletcher.com/).