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.
Implemented flows are:
- Client Credentials Grant
- Resource Owner Password Credentials Grant
Retrieve a client with access_token using Password Credentials Grant
1> oauth2c:retrieve_access_token(<<"password">>, <<"Url">>, <<"Uid">>, <<"Pwd">>).
{ok, Headers, Client}Retrieve a client with access_token using Client Credentials Grant
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:
3> oauth2c:request(get, json, <<"Url">>, [200], Client).
{{ok, Status, Headers, Body} Client2}See restclient for more info on how requests work.
The KIVRA oauth2 library uses an MIT license. So go ahead and do what you want!