diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f9df18f --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright (c) 2012 KIVRA + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 89478f7..aca2641 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,38 @@ -oauth2_client -============= +# Oauth2 Client +This library is designed to simplify consuming Oauth2 enabled REST Services. It wraps a restclient and takes care of reauthenticating expired access_tokens when needed. -Erlang OAuth2 Client \ No newline at end of file +## Flows + +Implemented flows are: + +- Client Credentials Grant +- Resource Owner Password Credentials Grant + +## Example + +Retrieve a client with access_token using Password Credentials Grant + +```erlang +1> oauth2c:retrieve_access_token(<<"password">>, <<"Url">>, <<"Uid">>, <<"Pwd">>). +{ok, Headers, Client} +``` + +Retrieve a client with access_token using Client Credentials Grant + +```erlang +2> oauth2c:retrieve_access_token(<<"client_credentials">>, <<"Url">>, <<"Client">>, <<"Secret">>). +{ok, Headers, Client} +``` + +The Opaque `Client` object is to be used on subsequent requests like: + +```erlang +3> oauth2c:request(get, json, <<"Url">>, [200], Client). +{{ok, Status, Headers, Body} Client2} +``` + +See [restclient](https://github.com/kivra/restclient) for more info on how requests work. + +## License +The KIVRA oauth2 library uses an [MIT license](http://en.wikipedia.org/wiki/MIT_License). So go ahead and do what +you want! diff --git a/rebar.config b/rebar.config index 216e8eb..657af22 100644 --- a/rebar.config +++ b/rebar.config @@ -1,3 +1,29 @@ +%% ---------------------------------------------------------------------------- +%% +%% oauth2: Erlang OAuth 2.0 Client +%% +%% Copyright (c) 2012 KIVRA +%% +%% Permission is hereby granted, free of charge, to any person obtaining a +%% copy of this software and associated documentation files (the "Software"), +%% to deal in the Software without restriction, including without limitation +%% the rights to use, copy, modify, merge, publish, distribute, sublicense, +%% and/or sell copies of the Software, and to permit persons to whom the +%% Software is furnished to do so, subject to the following conditions: +%% +%% The above copyright notice and this permission notice shall be included in +%% all copies or substantial portions of the Software. +%% +%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +%% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +%% DEALINGS IN THE SOFTWARE. +%% +%% ---------------------------------------------------------------------------- + {deps, [{restc, ".", {git, "git://github.com/kivra/restclient.git", {tag, "3cd1e2ce40"}}}]}. {erl_opts, [