README.txt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. {ok, RequestTokens} = oauth:tokens(oauth:get(RequestTokenURL, Consumer)),
  26. % If necessary, direct user to the Service Provider,
  27. % with Token = oauth:token(RequestTokens).
  28. {ok, AccessTokens} = oauth:tokens(oauth:get(AccessTokenURL, Consumer, RequestTokens)),
  29. oauth:get(ProtectedResourceURL, Consumer, AccessTokens, ExtraParams).
  30. Calling oauth:get or oauth:post returns an HTTP response tuple, as returned
  31. from http:request/4. Type "make termie", or look at the oauth_termie module
  32. for a working example. Thanks Andy!
  33. Alternatively, you can use oauth_request:header/6 to generate an HTTP
  34. Authorization header, as described by http://oauth.net/core/1.0/#auth_header.
  35. This isn't (currently) integrated into oauth:get and oauth:post, so you would
  36. need to use http:request/4 directly in this case.
  37. Who can I contact if I have another question?
  38. ---------------------------------------------
  39. Tim Fletcher (http://tfletcher.com/).